Skip to content

[BUG]: unable to add github apps to bypassers #2236

Open

Description

@jamesgeddes

Expected Behavior

should be able to add a github app (bot) to PR bypassers, as indicated by the docs;

pull_request_bypassers: (Optional) The list of actor Names/IDs that are allowed to bypass pull request requirements. Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.

Can add a GitHub app using the GUI, but not in Terraform. When a GitHub app is manually added to the PR bypassers in the GUI, it shows up in terraform as [org name]/[app username].

NB This was tested within a GitHub org using a github app that had been granted all permissions.

Actual Behavior

terraform apply returned the following error.

github_branch_protection.trunk_protection["test-trunk-protection"]: Modifying... [id=***]
github_branch_protection.trunk_protection["test-trunk-protection"]: Still modifying... [id=***, 10s elapsed]
github_branch_protection.trunk_protection["test-trunk-protection2"]: Still modifying... [id=***, 10s elapsed]

Error: Could not resolve to a node with the global id of ''

  with github_branch_protection.trunk_protection["test-trunk-protection2"],
  on github.tf line 38, in resource "github_branch_protection" "trunk_protection":
  38: resource "github_branch_protection" "trunk_protection" {


Error: Could not resolve to a node with the global id of ''

  with github_branch_protection.trunk_protection["test-trunk-protection"],
  on github.tf line 38, in resource "github_branch_protection" "trunk_protection":
  38: resource "github_branch_protection" "trunk_protection" {

fails when specifying github app as,

  • [org name]/[app login] (the format returned by a terraform plan!)
  • /[org name]/[app login]
  • [app user id]
  • /[app user login]
  • /[app user login][bot]
  • [app installation id]

Terraform Version

Terraform v1.8.0
GitHub provider v6.2.1

Affected Resource(s)

github_branch_protection

Terraform Configuration Files

resource "github_branch_protection" "trunk_protection" {
  pattern                         = "main"
  repository_id                   = "test-trunk-protection"
...
  required_pull_request_reviews {
    pull_request_bypassers = compact(concat(
      ["/jamesgeddes"],         # This human user works as expected.
    ))
  }
}

resource "github_branch_protection" "trunk_protection2" {
  pattern                         = "main"
  repository_id                   = "test-trunk-protection2"
...
  required_pull_request_reviews {
    pull_request_bypassers = compact(concat(
      ["/jamesgeddes"],         # This human user works as expected.
      ["geddesfamily/gedbot"],  # As soon as this GitHub app is added, Terraform returns the aforementioned error.
    ))
  }
}

Steps to Reproduce

  1. run terraform plan and terraform apply with no pull_request_bypassers
  2. manually add github app to github branch protection gui
  3. terraform plan shows [org name]/[app username] to remove
  4. add [org name]/[app username] to terraform pull_request_bypassers
  5. run terraform plan - note github app is accepted
  6. runterraform apply - note Error: Could not resolve to a node with the global id of '' error

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Pinned by deiga

Activity

  1. added
    Status: Triage
    Type: Bug
    on Apr 21, 2024
  2. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon Apr 22, 2024
  3. added
    Status: Up for grabs
    and removed
    Status: Triage
    on May 3, 2024
  4. carl-knutson commented on Jun 13, 2024

    @carl-knutson

    fails when specifying github app as,

    Also attempted the following with same results:

    • /[node-id]
    • [node-id]
  5. ivanmartos commented on Jul 10, 2024

    @ivanmartos
    Contributor

    Still valid with provider version 6.2.2

  6. msharbaji commented on Aug 22, 2024

    @msharbaji

    Is there a plan to fix this issue?

  7. tobias-farrenkopf commented on Sep 17, 2024

    @tobias-farrenkopf
  8. rtkwlf-hzzz commented on Oct 4, 2024

    @rtkwlf-hzzz

    As a workaround you can provide the node-id which you can get from the rest api: https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28

    hi @tobias-farrenkopf , we also encountered this issue recently, would you mind providing some details about how to use this workaround ....

    we try

     pull_request_bypassers = ["A_ID"]
    

    but it doesn't work. appreciat it in advance 🙏🙏

  9. Mabog10 commented on Nov 8, 2024

    @Mabog10

    Hello, below solution works in my case:

    github provider version: 6.3.1

    1. Use data source providing your GitHub App name:
    data "github_app" "this" {
      slug = "github_app_name"
    }
    
    1. Use "node_id" from data source in your code:
      required_pull_request_reviews = {
        pull_request_bypassers = [
          data.github_app.this.node_id
        ]
      }
    
  10. jamesgeddes commented on Nov 13, 2024

    @jamesgeddes
    Author

    Super! If this is intended functionality, then this has just become a request for documentation 😂

  11. Erwan-loot commented on Dec 24, 2024

    @Erwan-loot

    data "github_app" "this" {
    slug = "github_app_name"
    }

    Doesn't work at all when your app is private

  12. 10 remaining items

  13. Sytten commented on Dec 8, 2025

    @Sytten

    Very simple example @stevehipwell: GitHub Rulesets don’t have a "Dismiss stale reviews" option

  14. stevehipwell commented on Dec 8, 2025

    @stevehipwell
    Collaborator

    @Sytten I think you might be mistaken.

  15. Sytten commented on Dec 8, 2025

    @Sytten

    Ha looks like it @stevehipwell , I swear I did check not that long ago. This was one of blockers we had to switching.
    Maybe it was just not supported in the terraform provider?

  16. stevehipwell commented on Dec 9, 2025

    @stevehipwell
    Collaborator

    @Sytten if you want I can look back at our history for when we switched over to rulesets as it's one of the foundational constraints we require and we were early adopters? The TF provider implementation hasn't always been perfect, which is partially down to the API, but neither was the branch protection implementation.

  17. deiga commented on Dec 9, 2025

    @deiga
    Collaborator

    The only API limitation I currently know of that still requires using branch_protection: Deployment Environments configured on protected branches only consider branch_protection rules and not repo/org_ruleset.

    There might of course be TF provider limitations, but we're working on those! It's my personal highest priority, since I want our ClickOps Org Rulesets into Terraform 😬

  18. stevehipwell commented on Dec 9, 2025

    @stevehipwell
    Collaborator

    @deiga deployment environments should explicitly call out the refs that can deploy to them, otherwise it's likely that there will be misconfiguration as it's perfectly valid to apply (different) rules to all repo refs. Take for example this repo, until recently there was a branch protection for all refs (*) so an environment protection using protected would have been useless.

  19. deiga commented on Dec 9, 2025

    @deiga
    Collaborator

    @deiga deployment environments should explicitly call out the refs that can deploy to them, otherwise it's likely that there will be misconfiguration as it's perfectly valid to apply (different) rules to all repo refs. Take for example this repo, until recently there was a branch protection for all refs (*) so an environment protection using protected would have been useless.

    That is a good point yeah. Especially when managing all of this via TF. We are still part way in ClickOps land, where the protected branches made more sense

  20. stevehipwell commented on Dec 9, 2025

    @stevehipwell
    Collaborator

    We originally had protected branches but as soon as it was viable (actually before as we used a lifecycle ignore to stop the provider erroring) we switched over to rulesets as we could configure these across a whole organization.

  21. added and removed
    Status: Up for grabs
    on Jul 21, 2026
  22. added theissue type on Jul 22, 2026
  23. jazanne commented on Aug 21, 2026

    @jazanne

    any updates?

  24. deiga commented on Aug 21, 2026

    @deiga
    Collaborator

    @jazanne This would be the most relevant update: #2236 (comment)

  25. tkosushi commented on Nov 13, 2026

    @tkosushi

    Additional reproduction details for the private-App case on integrations/github v6.13.0, Terraform v1.16.4 (linux_amd64, remote execution).

    The data.github_app.<name>.node_id workaround does not resolve the failure in our setup. Unlike the original report's empty ID, our error contains the exact, non-empty node ID returned by the REST API.

    Setup and Terraform behavior

    • The provider authenticates using app_auth as GitHub App A, with an installation in the organization.
    • The intended bypass actor is a different, private, organization-owned GitHub App B, installed on all repositories in that organization.
    • App A has repository Administration read/write permission.
    • data.github_app successfully reads App B. The plan adds its node_id to required_pull_request_reviews.pull_request_bypassers.
    • Updating the existing github_branch_protection fails with Could not resolve to a node with the global id of '<APP_B_NODE_ID>'.

    Relevant configuration, reduced and anonymized from the failing configuration (not a separately tested standalone fixture):

    provider "github" {
      owner = var.organization
      app_auth {
        id              = var.app_a_id
        installation_id = var.app_a_installation_id
        pem_file        = var.app_a_private_key
      }
    }
    
    data "github_app" "bypass_app" {
      slug = var.app_b_slug
    }
    
    resource "github_branch_protection" "main" {
      repository_id = var.repository_name
      pattern       = "main"
      enforce_admins = true
    
      required_pull_request_reviews {
        require_code_owner_reviews      = true
        required_approving_review_count = 1
        pull_request_bypassers          = [data.github_app.bypass_app.node_id]
      }
    }

    API-level isolation, without Terraform

    Using an installation token minted for App A, with no additional repository or permission narrowing:

    1. GET /apps/<APP_B_SLUG> succeeds and returns App B's numeric id, node_id, and slug.
    2. A GraphQL query using the same authentication context and that exact node_id fails:
    query {
      node(id: "<APP_B_NODE_ID>") {
        id
        __typename
        ... on App { slug }
      }
    }
    {
      "data": { "node": null },
      "errors": [{
        "type": "NOT_FOUND",
        "path": ["node"],
        "message": "Could not resolve to a node with the global id of '<APP_B_NODE_ID>'."
      }]
    }
    1. The identical GraphQL query succeeds using our human user's gh authentication, returning __typename: "App" and the same node ID and slug.

    The REST and GraphQL checks used separately minted tokens for the same App A installation; neither token requested reduced permissions or repository scope. No credentials or actual organization/App identifiers are included here.

    This isolates an authentication-dependent REST/GraphQL visibility difference, rather than an empty or incorrect node ID. It does not establish whether the cause is a GitHub API limitation/bug or something the provider can address. We have not tested changing App B to public, a REST-based branch-protection update, or a ruleset migration.

    Is this a known upstream restriction when one installation token resolves another private App through GraphQL? If so, could the provider document the limitation/workaround, or is there an upstream GitHub issue/support route we should use for this reproduction?

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

    Type: Bugr/branch_protection

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions