Skip to content

Unable to create Custom Repository Role without permissions #3226

@andriyun

Description

@andriyun

In the current implementation, the client allows you to request a Custom Repository Role for an Organization without specifying the required keys.
CreateCustomRepoRole use as argument opts *CreateOrUpdateCustomRoleOptions which has all key as optional https://github.com/google/go-github/blob/master/github/orgs_custom_roles.go#L60

As a result, the client will allow the creation request to GitHub and will fail with an error.

In most cases, what is missing might be clear and reasonable.

But it doesn't work when creating a custom role with no permissions. In other words when CreateCustomRepoRole gets an empty array as a Permission key.

Due to omitempty in JSON tag of the Permission key, an empty array as value is omitted from the final request to GitHub API, while it is required by the API

In our case, we are using custom roles that might have empty permissions set for flexibility's sake to extend them in the future

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions