Skip to content

Stop preview cleanup from deleting other PRs' previews - #4626

Merged
akira28 merged 1 commit into
mainfrom
fix/preview-cleanup-prefix-collision
Oct 28, 2026
Merged

akira28 merged 1 commit into
mainfrom
fix/preview-cleanup-prefix-collision

Conversation

@akira28

@akira28 akira28 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Closing a pull request no longer deletes the previews of other pull requests whose number starts with the same digits.

Affects: Deploys & previews

Prompt summary: Check that the shared preview cleanup on main works, especially the S3 delete. The review found that the delete matches by key prefix, so the author asked for the one-character fix.

Why

preview-cleanup.yml runs aws s3 rm on .../docs/${PR_NUMBER} with --recursive, and the CLI deletes every key that starts with that string. Closing PR 461 removes the previews of PRs 4610 to 4619 as well, and PR 4619 would also match a future PR 46190. The same applies to the pull folder of the docs preview. The delete in the cleanup run for #4619 touched only docs/4619/, because no longer numbers exist yet.

What

Preview cleanup delete

The S3 path now ends in a slash, so the delete only matches keys inside the closed PR's own folder. Previews upload to <folder>/<number>/, so every object of that PR is still removed.

Verify

Close a pull request that has a preview and open the Delete s3 objects step of the cleanup run. Every delete: line should sit under .../<folder>/<number>/.

Out of scope: the fix is untested against a live bucket, because pull_request_target runs the base branch's workflow and main does not carry it yet. The first PR closed after the merge shows it in the cleanup log.

Risk: this workflow deletes objects in the shared preview bucket. A revert restores the old prefix match, but it does not restore objects already deleted.

🤖 Generated with Claude Code

`aws s3 rm` matches by key prefix, so the cleanup for PR 461 also removed the previews for PRs 4610 to 4619. A trailing slash limits the delete to the closed PR's own folder.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@akira28 akira28 added the bug label Oct 28, 2026
@akira28
akira28 requested a review from a team as a code owner October 28, 2026 12:50
@akira28
akira28 requested a review from reakaleek October 28, 2026 12:50
@akira28
akira28 merged commit 1630d2f into main Oct 28, 2026
44 checks passed
@akira28
akira28 deleted the fix/preview-cleanup-prefix-collision branch October 28, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant