Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: github_repository.name change should always be applied last to prevent errors #2451

Open
1 task done
garysassano opened this issue Nov 5, 2024 · 1 comment
Open
1 task done
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@garysassano
Copy link
Contributor

garysassano commented Nov 5, 2024

Expected Behavior

I had a Terraform plan with the following two resources:

  • github_repository
  • github_repository_collaborators

I modified both github_repository.name and github_repository_collaborators.team

The plan showed the following:

! github_repository.this["my-repo"] will be updated in-place
! github_repository_collaborators.repository_teams["my-repo"] must be replaced

I applied and expected everything to work just fine.

Actual Behavior

  1. The GitHub repository was renamed.
  2. Terraform tried to update the collaborators on the repository, but since the repository had been renamed in the previous step, Terraform could no longer find it and threw the following error:
Error: DELETE https://api.github.com/orgs/<ORG_NAME>/teams/<TEAM_SLUG>/repos/<ORG_NAME>/<REPO_NAME>: 404 Not Found []

To avoid this issue, the GitHub Terraform provider should implement the following logic:

  1. Check if the Terraform plan is trying to modify the github_repository.name attribute.
  2. If the plan is modifying the repository name, review all the other resources in the plan that reference that GitHub repository.
  3. Apply the changes to all the dependent resources first, and then apply the change to the github_repository resource last.

This ensures that no resources will try to interact with a GitHub repository that no longer exists, as you've already updated all the references to the old repository name before actually renaming the repository in the final step.

Terraform Version

v1.9.8

Affected Resource(s)

  • github_repository
  • github_repository_collaborators

Terraform Configuration Files

No response

Steps to Reproduce

No response

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@garysassano garysassano added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Nov 5, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Triage in 🧰 Octokit Active Nov 5, 2024
@MatthewHou
Copy link

Just ran into this issue when a team asked to rename their repo! I wonder if repositories should be identified by ids instead of names under the hood

@nickfloyd nickfloyd moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

2 participants