refactor!: Split CreateOrUpdateCustomRepoRoleOptions into CreateCustomRepoRoleRequest and UpdateCustomRepoRoleRequest and pass by value#4401
Open
JamBalaya56562 wants to merge 2 commits into
Conversation
…stomRepoRoleRequest` and `UpdateCustomRepoRoleRequest` and pass by value The create and update endpoints have different required fields, so the shared options type is split into two request types. On create, name, base_role and permissions are required, so `Name` and `BaseRole` become non-pointer strings without omitempty. On update every field is optional, so `UpdateCustomRepoRoleRequest` keeps them all as pointers. Both `OrganizationsService.CreateCustomRepoRole` and `UpdateCustomRepoRole` now take their request body by value, and the old type is removed from the .golangci.yml allowlists. BREAKING CHANGE: CreateOrUpdateCustomRepoRoleOptions is split into CreateCustomRepoRoleRequest (with non-pointer Name and BaseRole) and UpdateCustomRepoRoleRequest; OrganizationsService.CreateCustomRepoRole and UpdateCustomRepoRole now take these request types by value.
gmlewis
reviewed
Jul 22, 2026
With `omitempty` an empty slice is indistinguishable from a nil one, so
callers could not send an explicit empty array to clear the additional
permissions on a role. `omitzero` only omits the nil slice, so a nil value
leaves the permissions untouched while `[]string{}` sends `"permissions": []`.
This matches the existing use of `omitzero` for slices where an empty array
is meaningful, such as `ActionsAllowed.PatternsAllowed` and
`DeploymentRequest.RequiredContexts`.
gmlewis
approved these changes
Jul 22, 2026
gmlewis
left a comment
Collaborator
There was a problem hiding this comment.
Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4401 +/- ##
=======================================
Coverage 97.52% 97.52%
=======================================
Files 193 193
Lines 19668 19668
=======================================
Hits 19182 19182
Misses 268 268
Partials 218 218 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jvm986
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues the request-body-by-value work in #3644, this time for the custom repository role endpoints on
OrganizationsService.CreateOrUpdateCustomRepoRoleOptionswas a single type shared by both the create and update methods, but the two endpoints don't share the same required fields:namebase_rolepermissionsdescriptionSo the shared type is split into two request types, matching the split done for deployment branch policies in #4382:
CreateCustomRepoRoleRequest—NameandBaseRolebecome non-pointerstring(noomitempty) since they're required;Permissionsstays required;Descriptionstays optional (*string).UpdateCustomRepoRoleRequest— every field is optional, so all stay pointers (withPermissionsgainingomitempty).CreateCustomRepoRoleandUpdateCustomRepoRolenow take their body by value, and both entries are removed from the.golangci.ymlallowlists. The method verbs already match the docs operation names (Create / Update), so no method rename is needed. The response typeCustomRepoRolesis unchanged.Verified with
go build ./...,go vet -tags integration ./test/integration/,gofmt, the full./github/test suite (both methods and the regenerated accessors at 100%), andcustom-gcl(noparamcheckfindings after removing the allowlist entries).Updates #3644
BREAKING CHANGE: CreateOrUpdateCustomRepoRoleOptions is split into CreateCustomRepoRoleRequest (with non-pointer Name and BaseRole) and UpdateCustomRepoRoleRequest; OrganizationsService.CreateCustomRepoRole and UpdateCustomRepoRole now take these request types by value.
cc @jvm986 — flagging for #3644 coordination; this is in the
orgsservice, so it shouldn't overlap with theIssueswork.