Skip to content

[BUG]: github_repository_environment: can_admins_bypass = false is silently not applied on Pro/Team private repos #3760

Backlog

Description

@ayanich

Versions

Provider v6.13.0, OpenTofu 1.13, GitHub.com Pro (personal account), private repository.

Configuration

resource "github_repository_environment" "production" {
  repository        = "example"
  environment       = "production"
  can_admins_bypass = false
  deployment_branch_policy {
    protected_branches     = false
    custom_branch_policies = true
  }
}

Expected behavior

The environment has can_admins_bypass: false, or the apply fails.

Actual behavior

The apply reports Modifications complete. GitHub keeps can_admins_bypass: true and updated_at doesn't change. Every later plan shows can_admins_bypass = true -> false again.

Cause

go-github's CreateUpdateEnvironment gets a 422 on these plans. It then retries with only deployment_branch_policy and returns success (google/go-github#4727). The provider can't notice, because resourceGithubRepositoryEnvironmentUpdate (and Create) discard the returned Environment and don't read it back.

Suggestion

Compare the Environment returned by CreateUpdateEnvironment with what was sent, and return an error when can_admins_bypass or prevent_self_review differ. Or read the environment back after a write, so the mismatch surfaces as an inconsistent-result error. Either one turns silent drift into a failed apply. It still matters after google/go-github#4727 is fixed, for any field GitHub accepts and ignores.

Activity

  1. github-actions commented on Nov 30, 2026

    @github-actions

    👋 Hi, and thank you for opening this issue!

    This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

    You can help us prioritize by adding details, reproduction steps, or a 👍 to issues that matter to you, and by joining the discussion on open issues.


    🤖 This is an automated message.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions