- 
                Notifications
    
You must be signed in to change notification settings  - Fork 881
 
Handle error management on resources when dealing with archived repos. #2837
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
Conversation
| 
           cc: @gallowaystorm  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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!