Skip to content

[wrangler] add validation to actions that could affect r2 data catalog state with override option#12852

Merged
edmundhung merged 1 commit intocloudflare:mainfrom
Carolx715:cxu/data-catalog-check
Mar 25, 2026
Merged

[wrangler] add validation to actions that could affect r2 data catalog state with override option#12852
edmundhung merged 1 commit intocloudflare:mainfrom
Carolx715:cxu/data-catalog-check

Conversation

@Carolx715
Copy link
Copy Markdown
Contributor

@Carolx715 Carolx715 commented Mar 11, 2026

Data catalog errors are difficult to recover from, and users sometimes aren't aware that an action could delete or overwrite files from their buckets that could cause them. This change ensures R2 object and lifecycle commands now validate by default on actions that could leave data catalog-enabled buckets in an invalid state. By default, Wrangler will perform the catalog check with the header set, handle a 409 with an interactive prompt, and then if the user confirms, the request will be executed without the header/if user cancels, the request will be cancelled. Wrangler also has a --force flag to override any checks in interactive mode.

Proxy environment variables detected. We'll use your proxy for fetch requests.

 ⛅️ wrangler 4.73.0 (update available 4.75.0)
─────────────────────────────────────────────
Resource location: remote 

Creating object "meow.jpg" in bucket "bucket-1".
✔ Data catalog is enabled for this bucket. Proceeding may leave the data catalog in an invalid state. Continue? … yes
Upload complete.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
      • built a local instance of wrangler and ran commands on that binary through a proxy that returns the real request format that R2 Gateway will return
    • Additional testing not necessary because:
      • local tests have been written
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is a flag addition to a few R2 commands, and has been added to the --help description

A picture of a cute animal (not mandatory, but encouraged)

   |\---/|
   | ,_, |
    \_`_/-..----.
 ___/ `   ' ,""+ \  sk
(__...'   __\    |`.___.';
  (_,...'(_,.`__)/'.....+

Open with Devin

@Carolx715 Carolx715 requested a review from a team as a code owner March 11, 2026 16:48
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/r2/catalog-force.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/cfetch/internal.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/bucket.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/misc.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/object.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/lifecycle.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/object.ts: [@cloudflare/wrangler]

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 11, 2026

🦋 Changeset detected

Latest commit: 3d1a391

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 17, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12852

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12852

miniflare

npm i https://pkg.pr.new/miniflare@12852

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12852

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12852

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12852

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12852

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12852

wrangler

npm i https://pkg.pr.new/wrangler@12852

commit: 3d1a391

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 17, 2026

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/tests/r2/bulk.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/r2/catalog-force.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/r2/object.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/cfetch/internal.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/bucket.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/misc.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/helpers/object.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/lifecycle.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/r2/object.ts: [@cloudflare/wrangler]

@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch from ea746f1 to c38ca56 Compare March 18, 2026 15:06
devin-ai-integration[bot]

This comment was marked as resolved.

@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch 2 times, most recently from ecd68e9 to 45113ee Compare March 20, 2026 19:59
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 23, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch 2 times, most recently from d8edebf to bdc00ae Compare March 23, 2026 15:37
@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch 4 times, most recently from d3d9c11 to 8cfded6 Compare March 24, 2026 22:22
Copy link
Copy Markdown
Member

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for all the hard work!

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 25, 2026
@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch from 8cfded6 to d877e66 Compare March 25, 2026 16:41
@Carolx715 Carolx715 force-pushed the cxu/data-catalog-check branch from d877e66 to 3d1a391 Compare March 25, 2026 16:48
@ReppCodes
Copy link
Copy Markdown
Contributor

LGTM!

@edmundhung edmundhung merged commit 6b50bfa into cloudflare:main Mar 25, 2026
53 of 54 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 25, 2026
petebacondarwin added a commit that referenced this pull request Mar 25, 2026
Update the 'batch create objects' e2e test snapshot to include the
new confirmation prompt added in #12852 for operations that could
affect R2 data catalog state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants