Skip to content

refactor!: Split CreateOrUpdateCustomRepoRoleOptions into CreateCustomRepoRoleRequest and UpdateCustomRepoRoleRequest and pass by value#4401

Open
JamBalaya56562 wants to merge 2 commits into
google:masterfrom
JamBalaya56562:refactor/3644-custom-repo-role-value-params
Open

refactor!: Split CreateOrUpdateCustomRepoRoleOptions into CreateCustomRepoRoleRequest and UpdateCustomRepoRoleRequest and pass by value#4401
JamBalaya56562 wants to merge 2 commits into
google:masterfrom
JamBalaya56562:refactor/3644-custom-repo-role-value-params

Conversation

@JamBalaya56562

Copy link
Copy Markdown
Contributor

Continues the request-body-by-value work in #3644, this time for the custom repository role endpoints on OrganizationsService.

CreateOrUpdateCustomRepoRoleOptions was a single type shared by both the create and update methods, but the two endpoints don't share the same required fields:

Field Create (POST) Update (PATCH)
name required optional
base_role required optional
permissions required optional
description optional optional

So the shared type is split into two request types, matching the split done for deployment branch policies in #4382:

  • CreateCustomRepoRoleRequestName and BaseRole become non-pointer string (no omitempty) since they're required; Permissions stays required; Description stays optional (*string).
  • UpdateCustomRepoRoleRequest — every field is optional, so all stay pointers (with Permissions gaining omitempty).

CreateCustomRepoRole and UpdateCustomRepoRole now take their body by value, and both entries are removed from the .golangci.yml allowlists. The method verbs already match the docs operation names (Create / Update), so no method rename is needed. The response type CustomRepoRoles is 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%), and custom-gcl (no paramcheck findings 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 orgs service, so it shouldn't overlap with the Issues work.

…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 gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Jul 22, 2026
Comment thread github/orgs_custom_repository_roles.go Outdated
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 gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.52%. Comparing base (e5f31b2) to head (db0c11e).
⚠️ Report is 1 commits behind head on master.

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.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants