Skip to content

Conversation

@stevehipwell
Copy link
Collaborator

@stevehipwell stevehipwell commented Dec 4, 2025

Resolves #2805
Resolves #2960

This PR improves on the code in #2487.


Before the change?

  • Org roles re-ran the read logic
  • Org roles didn't use a context correctly
  • github_organization_role didn't correctly support org only permissions

After the change?

  • Org roles don't re-read
  • Org roles use context
  • github_organization_role can support org only permissions or no permissions

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@stevehipwell stevehipwell added this to the v6.x version wrap up milestone Dec 4, 2025
@stevehipwell stevehipwell self-assigned this Dec 4, 2025
@github-actions github-actions bot added the Type: Bug Something isn't working as documented label Dec 4, 2025
Copy link
Contributor

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Would you be able to add a test case which reproduces the error from the reported issue?

Optional: true,
Computed: true,
ValidateDiagFunc: validateValueFunc([]string{"read", "triage", "write", "maintain", "admin"}),
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

question: GH API doesn't mark this as required, if you found that it IS required, could you add a comment here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The issue on this covers the error. Note that the GitHub REST API docs aren't great, especially in cases like this where the spec has changed.

This change is intentional, if none had been an option when I created the apartment for this resource this would have been the design I'd have chosen. Basically optional+ computed is best avoided if possible (which it often isn't). But if it works in some cases without this being set then this would be a major version change so I can change the implementation. I'm hoping the automation testing PRs are merged soon so this can be tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I've changed the implementation to have a default as this will be non-breaking. Based on the previous logic and the reported error it looks like the implementation broke when the API swapped out "" for "none".

I've added extra test coverage and I've tested this manually using the API/UI, but as this is an enterprise feature I can't directly run the unit tests.

Computed: true,
ValidateDiagFunc: validateValueFunc([]string{"read", "triage", "write", "maintain", "admin"}),
Required: true,
ValidateDiagFunc: validateValueFunc([]string{"none", "read", "triage", "write", "maintain", "admin"}),
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: There doesn't seem to be an option for none in https://docs.github.com/en/enterprise-cloud@latest/rest/orgs/organization-roles?apiVersion=2022-11-28#create-a-custom-organization-role

But is this an oversight on GH API docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, read the description text above.

@stevehipwell
Copy link
Collaborator Author

Would you be able to add a test case which reproduces the error from the reported issue?

@deiga there is already a test for the org role error, that worked prior to the API changing. The other error is a distributed system error that can't easily be tested, as it'd be proving a negative; but we do have tests. We've seen the same problem in other areas in the API and need to get rid of the re-read pattern. Interestingly the resource failing here is having to use a list for get pattern as the get API was a later addition and needs v68. Also interesting is that at least one report is from GHES.

Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

2 participants