-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: Handle null assignee in Copilot Seat Billing API response #3619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
github/copilot.go
Outdated
@@ -203,6 +203,9 @@ func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error { | |||
cp.PlanType = seatDetail.PlanType | |||
|
|||
switch v := seatDetail.Assignee.(type) { | |||
case nil: | |||
// Assignee can be null according to GitHub API specification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the documentation expectations here, but should this have a link to the GitHub API documentation? (I would have also mentioned the specific API version, but the Copilot API is technically in public preview and subject to change at any time)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the comment to include the documentation link and API version as you suggested!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3619 +/- ##
=======================================
Coverage 91.33% 91.33%
=======================================
Files 184 184
Lines 16169 16174 +5
=======================================
+ Hits 14768 14773 +5
Misses 1227 1227
Partials 174 174 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @sanjayy-gowdaa and @hutson!
LGTM.
Merging.
@sanjayy-gowdaa - please comment on the original issue that you would like to work on so that we can assign it to you so that others won't attempt to duplicate your efforts. Thank you!
Thank you, I’ll make sure to comment on the issue and get it assigned to me before starting work next time. |
Fix: Handle
null
assignee in Copilot API responseResolves #3616
🔧 Changes Made
UnmarshalJSON
method incopilot.go
:case nil:
branch to handlenull
assignee
values.cp.Assignee = nil
whenassignee
isnull
, instead of returning an error.copilot_test.go
:"Null Assignee"
to ensure theassignee: null
scenario is handled correctly and no error is thrown.🐛 Problem
The current implementation of
UnmarshalJSON
forCopilotSeatDetails
throws an error when theassignee
field isnull
, even though the GitHub API documentation explicitly states thatassignee
can benull
.