Handle error management on resources when dealing with archived repos.#2837
Merged
Handle error management on resources when dealing with archived repos.#2837
Conversation
Member
Author
|
cc: @gallowaystorm |
There was a problem hiding this comment.
Pull Request Overview
This PR adds handling for archived repositories in Terraform deletion operations to prevent API errors. When repositories are archived, GitHub makes them read-only, causing deletion operations to fail with 403 errors. The changes gracefully handle these errors by detecting archived repository status and logging informational messages instead of returning errors.
Key changes:
- Added utility functions to detect and handle archived repository errors
- Updated resource deletion methods for repository files and issue labels to gracefully skip deletion on archived repositories
- Added comprehensive test coverage for archived repository scenarios
- Updated documentation to inform users about the new behavior
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| github/repository_utils.go | Adds utility functions to detect archived repository errors and handle deletion gracefully |
| github/resource_github_repository_file.go | Updates file deletion to use new archived repository handler |
| github/resource_github_issue_label.go | Updates label deletion to use new archived repository handler |
| github/resource_github_issue_labels.go | Updates bulk label deletion with inline archived repository error handling |
| github/resource_github_repository_file_test.go | Adds test for file deletion on archived repositories |
| github/resource_github_issue_label_test.go | Adds test for label deletion on archived repositories |
| github/resource_github_issue_labels_test.go | Adds test for bulk label deletion on archived repositories |
| website/docs/r/repository_file.html.markdown | Documents new archived repository deletion behavior |
| website/docs/r/issue_label.html.markdown | Documents new archived repository deletion behavior |
| website/docs/r/issue_labels.html.markdown | Documents new archived repository deletion behavior |
Comments suppressed due to low confidence (1)
github/resource_github_issue_labels.go:202
- Setting the resource ID after a delete operation is incorrect. The delete function should remove the resource from state, not set an ID. Line 200 should be removed, and line 202 should use
:=instead of=sinceerris not declared earlier in the function scope.
d.SetId(repository)
err := d.Set("label", make([]map[string]interface{}, 0))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hypercycle
approved these changes
Oct 29, 2025
thorrsson
approved these changes
Oct 29, 2025
This was referenced Nov 6, 2025
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #737
Before the change?
After the change?
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!