Skip to content

fix: send minimal payload when archiving repositories - #3621

Open
krukowskid wants to merge 2 commits into
integrations:mainfrom
krukowskid:fix/archive-on-destroy-security-payload
Open

fix: send minimal payload when archiving repositories#3621
krukowskid wants to merge 2 commits into
integrations:mainfrom
krukowskid:fix/archive-on-destroy-security-payload

Conversation

@krukowskid

Copy link
Copy Markdown

Resolves #3620


Before the change?

When archive_on_destroy was enabled, the delete path built a full repository update payload. Re-sending security_and_analysis caused GitHub to reject the request with HTTP 422 when an organization-enforced security configuration was applied, even though the repository was archived.

After the change?

The archive request contains only {archived:true}. The regression test verifies the exact PATCH payload while security settings are present in Terraform state, and the acceptance test now exercises the archive-on-destroy path.

Pull request checklist

  • Schema migrations have been created if needed (not needed)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (no documentation changes needed)

Does this introduce a breaking change?

  • Yes
  • No

Testing

  • go test ./... -timeout=30s -parallel=4 -skip '^TestAcc' -count=1
  • go build ./...

AI use

This focused change was implemented with GitHub Copilot assistance and reviewed and tested locally before submission.


Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

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 joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Aug 28, 2026
@dekokun

dekokun commented Aug 31, 2026

Copy link
Copy Markdown

Not a maintainer — helping with review triage, so this is a comment rather than an approving review.

The change looks correct to me. Two things I verified that may save you time:

  • Removing the second acceptance step is right: with archived = true, delete takes the "already archived, nothing to do" early return, so the archive-on-destroy path was never exercised by that test. The update false -> true path is still covered around L184-202 of the same file.
  • Dropping d.Set("archived", true) is safe — it only fed resourceGithubRepositoryObject, and the state is discarded once delete returns.

One suggestion: the acceptance test runs the archive path at teardown but asserts nothing about the outcome. A CheckDestroy asserting GetArchived() == true would cover what #3620 actually reports.

I have not run the acceptance tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@krukowskid

Copy link
Copy Markdown
Author

Thanks for the suggestion. I added a CheckDestroy assertion that fetches the repository after Terraform destroy and verifies that it is archived. The unit test still verifies the exact minimal PATCH payload. Unit tests and the build pass locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r/repository Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: 422 error on repository deletion with archive_on_destroy = true and security configuration enforced on all repos

3 participants