Repository navigation
Description
Terraform Version
1.5.7 (and later, unaffected by TF core version)
Provider Version
v6.11.1 (confirmed still present at v6.13.0, the latest release as of this report)
Affected Resource(s)
- github_repository
Terraform Configuration Files
N/A — reproduces on any github_repository resource that is renamed out-of-band (i.e. name changes on an already-applied resource) between two terraform apply/terraform plan -refresh-only runs.
Expected Behavior
After a rename, terraform refresh/plan should observe the actual current repository name and either report no diff (if the config's name already matches) or a correct diff.
Actual Behavior
resourceGithubRepositoryRead (github/resource_github_repository.go) does:
repoName := d.Id()
...
repo, resp, err := client.Repositories.Get(ctx, owner, repoName)
...
_ = d.Set("name", repoName)client.Repositories.Get succeeds even when repoName is the old name, because the GitHub API transparently redirects a renamed repository's old-name lookup to the current one — repo in the response correctly reflects the new name (repo.GetName()), and every other field is set from that response (repo.GetDescription(), repo.GetFullName(), etc.). But name is set from the pre-read repoName local variable instead of repo.GetName(), so it never reflects the actual current name. Read also never calls d.SetId(...), so the resource's ID likewise never advances past the original name.
By contrast, both resourceGithubRepositoryCreate and resourceGithubRepositoryUpdate correctly call d.SetId(repo.GetName()) after their respective API calls (Update even has a comment noting exactly this hazard: "It's possible that repo.GetName() is different from repoName if the repository is renamed"). That same handling was never applied to Read.
Practical impact for consumers that track external identity by ID/name (e.g. Crossplane's upjet-based providers, which re-derive their external-name annotation from the Terraform ID on every reconcile): once a repository is renamed, Read keeps reporting the pre-rename name indefinitely, and any control loop that treats that as authoritative will keep trying to "correct" the live repository back to its old name.
Steps to Reproduce
terraform applyagithub_repositoryresource, e.g.name = "foo".- Rename the repository out-of-band (GitHub UI, or
gh repo rename bar -R owner/foo), so the live repo is nowowner/barbut the Terraform ID in state is stillfoo. terraform plan -refresh-only(or anyRead/RefreshWithoutUpgradeinvocation using the stale ID).- Observe: the read succeeds (via GitHub's redirect), but the refreshed
nameattribute (and the resource's ID) still showsfoo, notbar.
Suggested fix
In resourceGithubRepositoryRead, immediately after the client.Repositories.Get call:
d.SetId(repo.GetName())
...
_ = d.Set("name", repo.GetName())mirroring the existing Create/Update handling.
Activity
github-actions commentedon Aug 1, 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 Aug 1, 2026
This might be resolved in #3310 already. If it isn't it will be addedd there