Skip to content

fix(r2): abort stale multipart uploads#2303

Merged
riderx merged 1 commit into
mainfrom
codex/r2-multipart-abort-rule
May 20, 2026
Merged

fix(r2): abort stale multipart uploads#2303
riderx merged 1 commit into
mainfrom
codex/r2-multipart-abort-rule

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented May 20, 2026

Summary (AI generated)

  • Add a bucket-wide R2 lifecycle rule named Default Multipart Abort Rule.
  • Abort incomplete multipart uploads after 1 day using abortMultipartUploadsTransition.
  • Keep the existing deleted-after-7-days/ trash cleanup rule unchanged.
  • Update the R2 lifecycle README to document both tracked rules.

Motivation (AI generated)

The bucket already has a 7-day trash cleanup rule for recoverable deletes. The screenshot also shows the default multipart abort rule, and keeping it in the tracked JSON prevents wrangler r2 bucket lifecycle set from accidentally replacing it.

Business Impact (AI generated)

This keeps stale multipart upload parts from lingering in R2 while preserving the 7-day recovery window for intentionally trashed bundle objects.

Test Plan (AI generated)

  • bunx wrangler r2 bucket lifecycle set --help
  • git diff --check
  • bun -e "const fs = require('node:fs'); const config = JSON.parse(fs.readFileSync('cloudflare_workers/r2/lifecycle.capgo.json', 'utf8')); const trash = config.rules.find(rule => rule.id === 'delete-trash-after-7-days'); const multipart = config.rules.find(rule => rule.id === 'Default Multipart Abort Rule'); if (trash?.deleteObjectsTransition?.condition?.maxAge !== 604800) throw new Error('trash maxAge invalid'); if (multipart?.conditions?.prefix !== '') throw new Error('multipart prefix invalid'); if (multipart?.abortMultipartUploadsTransition?.condition?.maxAge !== 86400) throw new Error('multipart maxAge invalid');"
  • bun run cli:build via commit hook
  • bun typecheck via commit hook

Summary by CodeRabbit

  • Documentation

    • Updated R2 bucket documentation with lifecycle rule specifications.
  • Chores

    • Configured automatic cleanup of incomplete multipart uploads and aged deleted objects.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 63d999da-8d85-45e5-bff3-41bc86558259

📥 Commits

Reviewing files that changed from the base of the PR and between 27a22c7 and 8133ba6.

📒 Files selected for processing (2)
  • cloudflare_workers/r2/README.md
  • cloudflare_workers/r2/lifecycle.capgo.json

📝 Walkthrough

Walkthrough

This PR adds a multipart upload abortion lifecycle rule to the R2 capgo bucket configuration and documents both this new rule and the existing trash-prefix deletion rule in the README, including alignment notes to R2_TRASH_PREFIX in the backend utilities.

Changes

R2 Lifecycle Configuration Update

Layer / File(s) Summary
Multipart upload abortion rule configuration
cloudflare_workers/r2/lifecycle.capgo.json
New lifecycle rule Default Multipart Abort Rule added to abort incomplete multipart uploads globally after 1 day (86400 seconds) via abortMultipartUploadsTransition.
Lifecycle rule documentation
cloudflare_workers/r2/README.md
README updated to explicitly describe lifecycle.capgo.json rules: deletion of objects in deleted-after-7-days/ after 7 days (with alignment requirement to R2_TRASH_PREFIX) and abortion of incomplete multipart uploads after 1 day.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • Cap-go/capgo#2297: This PR's explicit lifecycle management of deleted-after-7-days/ trash prefix aligns with the move-to-trash behavior introduced in that PR for delayed object deletion.

Poem

🐰 A hare's R2 rules take shape,
Orphaned uploads meet their fate,
Trash waits seven days to escape,
Documentation seals their state.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a rule to abort stale multipart uploads in R2, which is the primary purpose of the PR.
Description check ✅ Passed The description provides a comprehensive summary, motivation, business impact, and detailed test plan, covering most required sections from the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/r2-multipart-abort-rule

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 20, 2026

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing codex/r2-multipart-abort-rule (8133ba6) with main (27a22c7)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx marked this pull request as ready for review May 20, 2026 08:27
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@riderx riderx merged commit 7c674cb into main May 20, 2026
42 checks passed
@riderx riderx deleted the codex/r2-multipart-abort-rule branch May 20, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant