Skip to content

misleading diff (false -> true) for merge settings when authenticated with restricted GitHub App token #3382

Open

Description

@adrian-gierakowski

Description

When using the integrations/github provider with a GitHub App token that has Administration: Read but lacks Contents: Write (push access), terraform plan shows a perpetual diff for repository merge settings even if they are already correctly configured on GitHub.

Current Behavior

The GitHub API omits merge settings (like allow_merge_commit, allow_squash_merge, etc.) from the repository response if the authenticated user lacks push access. The Terraform provider currently interprets these missing fields as false (or empty strings), leading to a diff where Terraform attempts to change them from false -> true (or similar) on every plan.

Expected Behavior

If these fields are missing from the API response due to permission restrictions, the provider should throw an error if all required information cannot be fetched from the api, explainind which permissions are needed.

Impact

Users wanting to perform "Read-only" plans or audits using restricted GitHub App tokens (following the principle of least privilege) are forced to either:

  • Grant Contents: Write (push access) just to get a clean plan.
  • Use lifecycle { ignore_changes = [...] }, which prevents Terraform from managing these settings even when using a high-privilege token.

Terraform Version

  • Provider: integrations/github v6.2.1 and v6.12.1

Relevant Permissions

  • Administration: Read
  • Contents: Read (Missing Write)

Activity

  1. github-actions commented on Apr 30, 2026

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  2. added
    Status: Triage
    on May 10, 2026
  3. deiga commented on May 10, 2026

    @deiga
    Collaborator

    This is already documented in the provider docs.

    What is the behaviour you would like to see? Without correct permissions Terraform can't know the correct diff to show.
    Should it throw an error instead? I don't know if it's possible to check missing permissions 🤔

  4. adrian-gierakowski commented on May 10, 2026

    @adrian-gierakowski
    Author

    Error would be the correct behaviour imho. Can missing properties be detected by simply looking at the payload, or are these optional a d could be missing even if requester has all permissions?

  5. deiga commented on May 10, 2026

    @deiga
    Collaborator

    I think that building a heuristic to determine from the payload if permissions are missing could be quite brittle and hard to maintain.
    But I seem to recall that some API call returns scopes in a Header 🤔

    If that's reasonable to use and ubiquitous enough, that could work in many other places as well.

    But throwing an error might still be an unexpected outcome, maybe we can return a warning for those fields...

  6. adrian-gierakowski commented on May 10, 2026

    @adrian-gierakowski
    Author

    Is there a valid use case for applying such resources with incomplete permissions?

  7. deiga commented on May 10, 2026

    @deiga
    Collaborator

    I'd say there is a valid use-case for seeing a plan with lacking permissions.
    And I guess applying should be possible as well without those permissions since the rest is applyable

  8. adrian-gierakowski commented on May 10, 2026

    @adrian-gierakowski
    Author

    I'd say there is a valid use-case for seeing a plan with lacking permissions. And I guess applying should be possible as well without those permissions since the rest is applyable

    But isn't the plan a bit useless given it shows a fictional diff based on defaults put in place missing properties? I guess the only case where it's not misleading is when the tf config doesn't include any of the properties which are not accessible due to missing permissions. Seems like there really should be (a) sperate resource(s) for the part(s) which require additional permissions.

  9. stevehipwell commented on May 26, 2026

    @stevehipwell
    Collaborator

    IMHO the provider is working as intended, the GitHub API shapes the response based on the auth scope and it's up to the user to make sure they have granted the privider the correct permissions. The provider can't ignore changes due to missing content from the response automatically, if you want this pattern you need to explicitly set ignores on the resource.

    If you're asking for the provider to gate resources based on permissions, we'd need a way to handle this in the plan phase; which would require full permissions at all times. I think this is what you're trying to avoid?

  10. Hixie commented on Oct 28, 2026

    @Hixie

    FWIW, it seems you can get this information with a read-only token via the GraphQL API.

  11. karlkeefer commented on Nov 20, 2026

    @karlkeefer

    @Hixie suggestion works for our tf drift check in CI (🙇‍♂️), which doesn't have contents: write - see #3741

  12. robert-crandall commented on Nov 25, 2026

    @robert-crandall
    Contributor

    Linking #3741 from @karlkeefer here for reference. We closed it as part of our temporary move to an issue-first model (see CONTRIBUTING.md), and want to keep the context and implementation approach handy when we pick this issue up.

  13. karlkeefer commented on Nov 25, 2026

    @karlkeefer

    Thanks @robert-crandall - happy to weigh in on any issues, or run tf plan against a proposed patch with my read-only tokens if/when this comes up later 🙌

  14. stevehipwell commented on Nov 27, 2026

    @stevehipwell
    Collaborator

    We only use GraphQL if we absolutely have to (and we're removing it wherever possible), this case doesn't meet that criteria as there is a fully functional REST API endpoint. The current provider behaviour is working as expected, you need to provide the right permissions for the resource to function correctly (or use a lifecycle block to ignore them). If you'd like to talk directly with GitHub to get parity between the REST and GraphQL API that'd be great, but that's not a provider issue.

    @robert-crandall I think this issue should be closed as wont fix.

  15. adrian-gierakowski commented on Nov 29, 2026

    @adrian-gierakowski
    Author

    The current provider behaviour is working as expected

    that depends on the definition of "expected". As far as I'm concern current behaviour makes for really shitty DX

    the fact that it's blocked by something you can't directly change doesn't make the issue disappear, I am happy to escalate this further but IMHO, the issue should remain open until it's actually fixed

    If you'd like to talk directly with GitHub to get parity between the REST and GraphQL API that'd be great, but that's not a provider issue

    Where should I submit the issue? thanks!

  16. stevehipwell commented on Nov 30, 2026

    @stevehipwell
    Collaborator

    that depends on the definition of "expected".

    Not really, it's more an issue of context. With the full context, this behaviour is expected as it's the way the system has been built and consistently observed.

    As far as I'm concern current behaviour makes for really shitty DX

    You wont get an argument against this position from me.

    the fact that it's blocked by something you can't directly change doesn't make the issue disappear, I am happy to escalate this further but IMHO, the issue should remain open until it's actually fixed

    It doesn't make it disappear, but it makes it part of the provider API surface.

    Where should I submit the issue? thanks!

    If you can figure this out please let me know. If you're an enterprise customer I'd suggest starting with your account team.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions