Repository navigation
Description
Expected Behavior
When creating a repository from a template with visibility = "internal", the operation should complete successfully without spurious 422 errors, and the desired visibility should be set reliably by Terraform. The provider should handle any normal GitHub-side settling delays internally (via retry/backoff) so users do not need to tune write_delay_ms or split operations across multiple applies.
Actual Behavior
Creating a repo from a template with visibility = "internal" frequently fails with:
Error: PATCH https://api.github.com/repos/[org]/[repo]: 422 Failed to update visibility. A previous repository operation is still in progress. []
This is because the provider uses the template generate endpoint (which only supports 'private', not 'internal'), and then immediately issues a PATCH to set 'internal' visibility without any retry/backoff when GitHub is not ready. Users need to add large write_delay_ms to get reliable applies, but is not feasible for this one issue.
Terraform Version
Terraform v1.9.5
- provider registry.terraform.io/integrations/github v6.11.1 (and v6.11.0)
Reproducible on current releases.
Affected Resource(s)
- github_repository (template create + visibility = "internal")
Terraform Configuration Files
resource "github_repository" "team_repos" {
name = "my-repo"
template {
owner = "my-org"
repository = "template-repo"
}
visibility = "internal"
auto_init = true
# additional fields as needed
}Steps to Reproduce
- Create a template repo (must be "internal" or "private")
- Use github_repository resource with that template and visibility = "internal"
- terraform apply
Result:
Randomly (often), the operation fails with 422 error above if provider attempts to PATCH visibility too quickly after repo creation.
Debug Output
Terraform apply output:
Error: PATCH https://api.github.com/repos/my-org/my-repo: 422 Failed to update visibility. A previous repository operation is still in progress. []
This repeats unless write_delay_ms is set to large values (2-10 seconds or more).
The provider code path is resourceGithubRepositoryCreate() followed by resourceGithubRepositoryUpdate() which issues the PATCH for visibility = "internal" with no retry.
Proposed Fix:
- In resourceGithubRepositoryUpdate(), add retry/backoff for PATCH /repos/:org/:repo when 422 'previous repository operation' is returned for visibility changes after template creation.
- See also PR #3123 (fixed template create, but not the PATCH retry).Panic Output
N/ACode of Conduct
- I agree to follow this project's Code of Conduct
Activity
github-actions commentedon Mar 24, 2026
👋 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! 🚀gwendal-lecren commentedon Jun 22, 2026
Ran into the same issue today with v6.12.0.
kbraithwaite commentedon Jul 22, 2026
Afternoon! We are also running into this issue on version
6.12.1.For now we have added 422 to the list of
retryable_errorsin the provider config, which should help mitigate this issue 🙏🏽deiga commentedon Jul 22, 2026
Thanks! This should be resolved in 6.14.0