r2 objects delete and bulk-delete exit 0 without deleting keys that contain '/'
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
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
cfinstalled 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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/cf
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/cf#344 ·
Maintainers usually reply within 1 day
-
upstream
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/cf#262 ·
Maintainers usually reply within 1 day
-
`cf dev` rejects `--port` and `--host` for Vite projects, including the `cf init` templatePossibly taken @jamesopstad claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/cf#223 · 2 assignees ·
Maintainers usually reply within 1 day
-
upstream
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cloudflare/cf#179 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
cloudflare/cf#347 ·
Maintainers usually reply within 1 day
Similar issues
-
The inspector never shows the instances field, so scaling out is unreachablePossibly taken @Mrkewl claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
xevrion/breakscale#96 ·
Maintainers usually reply within 4 days
-
Object parameters lose their structure when resources is enabledPossibly taken @asts-top claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rossant/awesome-math#199 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
jaegertracing/jaeger-ui#4618 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
mifi/lossless-cut#3125 ·
Maintainers usually reply within 1 day