Repository navigation
Description
Expected Behavior
When the GitHub API response for a ruleset omits bypass_actors, Read keeps the bypass_actors value already in state. A plan with no configuration change shows no diff.
Actual Behavior
GitHub omits bypass_actors from GET /repos/{owner}/{repo}/rulesets/{id} when the caller cannot administer the ruleset. An admin caller gets "bypass_actors": [] when the list is empty, so a missing key and an empty list mean different things.
The provider treats both the same. flattenBypassActors returns []any{} for a nil slice, and Read writes it to state unconditionally:
github/resource_github_repository_ruleset.go#L776github/resource_github_organization_ruleset.go#L866github/util_rules.go#L169-L171
Every plan run with such a token therefore proposes adding the configured bypass actors again:
# github_repository_ruleset.default_branch will be updated in-place
~ resource "github_repository_ruleset" "default_branch" {
+ bypass_actors {
+ actor_type = "OrganizationAdmin"
+ bypass_mode = "pull_request"
}
# ...
}
Our setup is a common one: the plan job runs with a read-only GitHub App installation token (no Administration write), and only the apply job holds an admin-capable token. The plan never converges.
go-github's RepositoryRuleset.BypassActors decodes a missing key as nil and [] as an empty slice, so Read can tell the two cases apart without an extra request.
Terraform Version
OpenTofu v1.13.1, provider integrations/github v6.13.0 (latest release). The code linked above is from main at 20f916cb.
GitHub Installation Type
- GitHub.com (Free, Pro, or Team)
Affected Resource(s)
github_repository_rulesetgithub_organization_ruleset(sameReadpattern)
Terraform Configuration Files
resource "github_repository_ruleset" "default_branch" {
name = "main"
repository = "example"
target = "branch"
enforcement = "active"
conditions {
ref_name {
include = ["~DEFAULT_BRANCH"]
exclude = []
}
}
bypass_actors {
actor_type = "OrganizationAdmin"
bypass_mode = "pull_request"
}
rules {
deletion = true
non_fast_forward = true
}
}Steps to Reproduce
- Apply the configuration above with a token that has admin rights on the repository.
- Run
planwith a token that can read the repository but cannot administer it, for example a GitHub App installation token without the Administration write permission. - The plan proposes
+ bypass_actors { ... }. Applying with the admin token and planning again with the read-only token shows the same diff.
The API difference is visible with gh api repos/<owner>/<repo>/rulesets/<id> --jq 'has("bypass_actors")': false for a non-admin caller, true for an admin caller, including when the list is empty.
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
github-actions commentedon Oct 19, 2026
👋 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 and PRs.
🤖 This is an automated message.
deiga commentedon Oct 20, 2026
@rriski This is not a bug, this is how Terraform is supposed to work.
I fully understand that using Read-only would be lovely, but that is up to the GitHub API team to introduce.
We can't start breaking the Terraform contract just to work around a deficit in the GitHub API
robert-crandall commentedon Nov 25, 2026
Linking #3688 from @rriski 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.