Skip to content

fix!: Resolve inconsistent options for create and update on custom org role#4075

Open
munlicode wants to merge 3 commits intogoogle:masterfrom
munlicode:fix/inconsistency-in-creating-and-updating-a-custom-organization-role
Open

fix!: Resolve inconsistent options for create and update on custom org role#4075
munlicode wants to merge 3 commits intogoogle:masterfrom
munlicode:fix/inconsistency-in-creating-and-updating-a-custom-organization-role

Conversation

@munlicode
Copy link
Contributor

@munlicode munlicode commented Mar 9, 2026

BREAKING CHANGE: CreateCustomOrgRole and UpdateCustomOrgRole now take their own options.

  • Split structs for CreateCustomOrgRole and UpdateCustomOrgRole into CreateOrgRoleOptions and UpdateOrgRoleOptions.
  • Set name required option on create operation.
  • Set all options to be optional on update operation.

Fixes: #4074.

… and `UpdateOrgRoleOptions` with appropriate structs for each operation
@gmlewis gmlewis changed the title fix: Resolve inconsistency in options for create and update operations on custom organization role fix: Resolve inconsistency in options for create and update on custom org role Mar 9, 2026
@gmlewis gmlewis changed the title fix: Resolve inconsistency in options for create and update on custom org role fix!: Resolve inconsistency in options for create and update on custom org role Mar 9, 2026
@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 Mar 9, 2026
@gmlewis gmlewis changed the title fix!: Resolve inconsistency in options for create and update on custom org role fix!: Resolve inconsist options for create and update on custom org role Mar 9, 2026
@gmlewis gmlewis changed the title fix!: Resolve inconsist options for create and update on custom org role fix!: Resolve inconsistent options for create and update on custom org role Mar 9, 2026
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.65%. Comparing base (16e8203) to head (29d7287).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4075   +/-   ##
=======================================
  Coverage   93.65%   93.65%           
=======================================
  Files         210      210           
  Lines       19416    19416           
=======================================
  Hits        18184    18184           
  Misses       1034     1034           
  Partials      198      198           

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

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, @munlicode!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

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

//
//meta:operation POST /orgs/{org}/organization-roles
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, opts *CreateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

CreateOrgRoleOptions are body parameters, but we typically use the Options  suffix for query parameters. Also, a request body is required when creating a custom org role.
Additionally, we are returning a role, not roles.

Therefore, I propose the following renamings:

CreateOrgRoleOptions -> CreateCustomOrgRoleRequest
CustomOrgRoles -> CustomOrgRole

Suggested change
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, opts *CreateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, request CreateCustomOrgRoleRequest) (*CustomOrgRole, *Response, error) {

We're breaking this endpoint anyway, so let’s do it in the best possible way.

Copy link
Contributor Author

@munlicode munlicode Mar 10, 2026

Choose a reason for hiding this comment

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

Would it not be confusing to have request and req ?

func (s *OrganizationsService) CreateCustomOrgRole(ctx context.Context, org string, request CreateCustomOrgRoleRequest) (*CustomOrgRole, *Response, error) {
	u := fmt.Sprintf("orgs/%v/organization-roles", org)

	req, err := s.client.NewRequest("POST", u, request)
	...

If it is fine, I am ready to rename opts to request.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can call it Body, but that would require significant refactoring.

And the Request prefix is common across the code base:

func (s *RepositoriesService) Transfer(ctx context.Context, owner, repo string, transfer TransferRequest) (*Repository, *Response, error) {

func (s *OrganizationsService) CreateNetworkConfiguration(ctx context.Context, org string, createReq NetworkConfigurationRequest) (*NetworkConfiguration, *Response, error) {

func (s *ActionsService) GenerateRepoJITConfig(ctx context.Context, owner, repo string, request *GenerateJITConfigRequest) (*JITRunnerConfig, *Response, error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

The parameter name can be simply create instead of request.

//
//meta:operation PATCH /orgs/{org}/organization-roles/{role_id}
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *CreateOrUpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *UpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above:

Suggested change
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, opts *UpdateOrgRoleOptions) (*CustomOrgRoles, *Response, error) {
func (s *OrganizationsService) UpdateCustomOrgRole(ctx context.Context, org string, roleID int64, request UpdateCustomOrgRoleRequest) (*CustomOrgRole, *Response, error) {

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.

Inconsistency in creating and updating a custom organization role

3 participants