fix: Handle string-typed reviewer ID in Ruleset API responses#4178
fix: Handle string-typed reviewer ID in Ruleset API responses#4178gmlewis merged 5 commits intogoogle:masterfrom
ID in Ruleset API responses#4178Conversation
|
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. |
|
Full disclosure: I'm not a go developer and have used agentic ai/coding to drive this implementation. Will take any feedback on board in an effort to provide a proper go solution in line with repository standards |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4178 +/- ##
==========================================
- Coverage 93.69% 93.69% -0.01%
==========================================
Files 210 210
Lines 19741 19760 +19
==========================================
+ Hits 18497 18514 +17
- Misses 1048 1049 +1
- Partials 196 197 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @mmelodyRTR!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode
|
@mmelodyRTR - if you want to make the PR even better, Codecov is reporting that the following line is not covered by a unit test. You could ask the agent to see if it can come up with a unit test that would cover the failure on line 498:
|
|
Thanks for the feedback @gmlewis - added a test case as requested 🫡 |
| }, | ||
| } |
There was a problem hiding this comment.
Codecov still claims it is not covered, but that's OK. We can proceed anyway.
ID in Ruleset API responses
|
Thank you, @mmelodyRTR and @Not-Dhananjay-Mishra! |
|
Thanks folks :) |


Summary
This PR addresses a JSON unmarshaling error in
RulesetReviewer.IDwhen interacting with the GitHub Repository Ruleset API.While the GitHub API documentation specifies that the reviewer ID should be an integer, the API currently returns these IDs as quoted strings (e.g.,
"id": "123456"). This causes the standard Go JSON decoder to fail when unmarshaling into the*int64field.Related Issues
This issue was identified via the GitHub Terraform Provider: integrations/terraform-provider-github/issues/3214
Changes
UnmarshalJSONforRulesetRevieweringithub/rules.go.*int64type forRulesetReviewer.IDto preserve consistency with the rest of the library and avoid breaking changes for existing users.TestRepositoryRuleand a new comprehensive unit test suiteTestRulesetReviewer_UnmarshalJSONingithub/rules_test.go.Verification
gh apiagainst a live repository.github/rules_test.go, which now pass with the fix.