fix(r2): local bulk delete reports absent keys as successful

Open
#17,037 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript

Research direction

Start by comparing the cf r2 objects bulk-delete help output with the local bulk-delete behavior described in the reproduction. The issue points to Miniflare’s packages/miniflare/src/workers/local-explorer/resources/r2.ts implementation; read the linked section and trace how missing keys are handled. Verify the mixed-key case reports one failure while deleting the existing key, and that an existing key alone still succeeds.

Written by the indexing model from the issue text.

Description

bug feature:local-explorer package:miniflare product:r2

Summary

cf r2 objects bulk-delete --local reports an absent key in its success output and exits 0. This makes a mixed existing-and-missing deletion look fully successful in a local script, although the command help specifies a failure entry for each missing key.

Steps to reproduce

Use the CLI described under Runtime or environment. Run these commands in a new temporary directory. The created first key is disposable, and absent is never written.

cf r2 objects put first --body sample --bucket-name sample-bucket --local --persist-to state
cf r2 objects bulk-delete --body '["first","absent"]' --force --bucket-name sample-bucket --local --persist-to state
cf r2 objects list --bucket-name sample-bucket --local --persist-to state

Expected behavior

The operation deletes first and reports a partial failure with one error entry, as described by CLI help. If the simulator deliberately supports an idempotent operation instead, local mode states that missing keys will be reported as successful before callers rely on the result.

Actual behavior

Both CLI builds exited 0. Stdout was [{"key":"first"},{"key":"absent"}] with no missing-key report. Listing after deletion confirmed first had been removed.

Runtime or environment

  • macOS 27.2 arm64, Node.js 26.13.1, npm 12.2.2.
  • Published cf 1.0.0-rc.1 and the current main CI package, both with bundled Miniflare 5.20261117.0-beta. The CLI README at that revision includes array-body bulk deletion among supported local operations.
  • A direct Local Explorer request on Miniflare 5.20261118.0-beta returned status 200 with success: true and both keys while removing first.

Evidence

  • Expected source: cf r2 objects bulk-delete --help describes success: false, result: null and one error entry for each failed key, including a missing key.
  • Failure source: The mixed-key request above exits 0 and lists both keys without an error. The Local Explorer bulk-delete implementation acknowledges the supplied keys after deletion. The issue is the resulting difference from the CLI's advertised behavior.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

Repeat the mixed-key case. first disappears from the bucket and the command surfaces one failure for the mixed-key request. If idempotent deletion is the supported local behavior, the CLI explains the local success semantics in its help and runtime output. A bulk delete containing only an existing key still succeeds.

References

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: Local tests can report a clean cleanup pass for a key that never existed and conceal how their script handles the documented partial-failure response.
  • Workaround status: unverified
  • Workaround basis: No local cf bulk-delete option was found that reports missing keys distinctly.
Dominant language
TypeScript
Stars
4.7k
Forks
1.7k
Avg merge
1d 22h
Merged PRs (30d)
282

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/workers-sdk

All issues in cloudflare/workers-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.