Handle repo rename edge case for team repository deletions #870
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is an apply
error
that can happen occasionally when you have a plan that:github_repository
github_team_repository
's to connect to the new repo name.Most times, such a plan works:
github_team_repository
's connected to the repogithub_repository
github_team_repository
's under the repo's new nameHowever, sometimes, steps 1 and 2 overlap in which case you'll get a 404 when you try to destroy a
github_team_repository
that is connected to a repo that has just been renamed.This GIST contains a sample
plan
andapply
of this edge case:https://gist.github.com/k24dizzle/36fbc3921c7a074168bee287263df02b
See this repo for example tf config that could run into this error: https://github.com/kzhaotest/team_repo_edge_case
This PR takes advantage of a quirk of the github API to fix this edge case. If you try to get a repo that has just been renamed, you can still access it via the API under the old name, to get the new name of the repo. Then you can use the new name to delete the
github_team_repository
.