Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

r2 objects delete and bulk-delete exit 0 without deleting keys that contain '/'

Open
#209 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
node.js, typescript
Domain
cli

Research direction

Start by locating the r2 objects delete and bulk-delete command implementations and their request-path construction; compare that behavior with the issue's reference to #113 and the CLI help text about literal slashes. Reproduce with a key containing / and inspect the generated request path. Done when both commands delete the exact key and a missing key is not reported as a successful deletion without notice.

Written by the indexing model from the issue text.

Description

upstream
Summary of the issue

cf r2 objects delete and cf r2 objects bulk-delete report success but delete nothing when the object key contains /.

The CLI percent-encodes / in the key as %2F in the request path, the same root cause as #113 for put. R2 answers a DELETE for a key that does not exist with success, so the command exits 0, prints no error, and the real object stays in place. Nothing tells the user that the delete missed.

cf r2 objects get builds the path the same way (--dry-run shows %2F), but it returned the correct object body in our tests, so only deletes failed silently.

This is easy to miss in cleanup scripts. Ours reported 2,220 objects deleted with zero errors, and a re-listing showed that all of them were still in the bucket.

Expected behaviour

The CLI follows its own help text: "Slashes (/) within the key MUST be sent literally and MUST NOT be percent-encoded". The delete removes the object at the given key.

If the request does not match an existing key, the CLI should at least say so instead of exiting 0 silently.

Version of cf used

1.0.0-beta.12

System information and package versions
  • macOS 26.6.2 (arm64)
  • Node.js v22.22.2
  • cf installed globally with npm
  • wrangler 4.77.0, used as the working comparison
Reproduction (optional)
export CLOUDFLARE_ACCOUNT_ID=<account>
echo hi > /tmp/a.txt
cf r2 objects put folder/a.txt --bucket-name <bucket> --file /tmp/a.txt --content-type text/plain

cf r2 objects delete folder/a.txt --bucket-name <bucket> --dry-run
# url ends with .../objects/folder%2Fa.txt

cf r2 objects delete folder/a.txt --bucket-name <bucket>   # exit 0, no error
cf r2 objects list --bucket-name <bucket> --prefix folder/ # object is still listed

wrangler r2 object delete <bucket>/folder/a.txt --remote   # actually deletes it

The bulk-delete delete-by-list mode (--body '["folder/a.txt"]') also exits 0 and leaves the object in place.

Relevant error logs (optional)

There are no errors, which is the problem.

Dominant language
TypeScript
Stars
853
Forks
42
Avg merge
17h 57m
Merged PRs (30d)
146

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/cf

All issues in cloudflare/cf

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.