+
Skip to content

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

Merged
merged 2 commits into from
Jul 2, 2025

Conversation

sanjayy-gowdaa
Copy link
Contributor

@sanjayy-gowdaa sanjayy-gowdaa commented Jul 1, 2025

Fix: Handle null assignee in Copilot API response

Resolves #3616

🔧 Changes Made

  • Fixed UnmarshalJSON method in copilot.go:
    • Added a case nil: branch to handle null assignee values.
    • Sets cp.Assignee = nil when assignee is null, instead of returning an error.
  • Updated copilot_test.go:
    • Added a unit test case "Null Assignee" to ensure the assignee: null scenario is handled correctly and no error is thrown.

🐛 Problem

The current implementation of UnmarshalJSON for CopilotSeatDetails throws an error when the assignee field is null, even though the GitHub API documentation explicitly states that assignee can be null.

Copy link

google-cla bot commented Jul 1, 2025

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.

@@ -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
Copy link

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)

Copy link
Contributor Author

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!

@sanjayy-gowdaa sanjayy-gowdaa requested a review from hutson July 1, 2025 22:47
Copy link

codecov bot commented Jul 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.33%. Comparing base (eff2bbd) to head (0e5803b).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis changed the title Fix: Handle null assignee in Copilot Seat Billing API response fix: Handle null assignee in Copilot Seat Billing API response Jul 2, 2025
Copy link
Collaborator

@gmlewis gmlewis left a 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!

@gmlewis gmlewis merged commit 21c2976 into google:master Jul 2, 2025
7 checks passed
@sanjayy-gowdaa
Copy link
Contributor Author

Thank you, I’ll make sure to comment on the issue and get it assigned to me before starting work next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Copilot Seat Billing API response for the assignee type can be "null"
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载