You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cf r2 objects bulk-delete cannot empty a bucket or delete by prefix: --body is required even with --prefix #21
cf r2 objects bulk-delete documents three modes. Two of them, delete by prefix and empty bucket, take the prefix query parameter and no request body. The command cannot run either mode, because the handler throws when --body is absent.
The CLI sends DELETE /accounts/{account_id}/r2/buckets/{bucket_name}/objects?prefix= without a body and prints the job descriptor.
Actual
◇ This permanently deletes the selected R2 objects. An explicitly empty prefix deletes every object in the bucket while retaining
│ the bucket itself. Continue?
│ Yes
┌ Error
│ --body is required for this command. Pass --body '<json>' or --body @path/to/file.json.
The CLI sends no request and the bucket is unchanged.
--dry-run with the same flags passes. It prints the correct URL and "query": { "prefix": "" }, so the dry run does not show the problem.
Cause
In packages/cli/src/commands/_generated/r2/objects/bulk-delete.ts the handler sends the request only inside the if (argv.body) branch. After that branch it throws when argv.body === undefined. There is no path that sends the request without a body.
The help text for --body says the body is "Ignored when prefix is provided", which matches the API but not the handler.
From reading the same code, --body "" looks like a second problem. The value is defined but falsy, so the handler would send nothing and throw nothing. I did not run that case.
Workaround
The same request sent directly to the API without a body works and returns the job descriptor:
When prefix is present, send the request without a body. Require --body only when prefix is omitted.
The generator may need a way to mark a request body as conditional. cf schema r2 objects bulk-delete reports "hasRequestBody": true with an empty requestBodyFields, and the generated handler treats that as always required. Other generated commands with an optional body may have the same behaviour.
Still reproduces on cf 1.0.0-beta.10 (macOS, Node 24.3.0), and with a non-empty prefix too, not only --prefix=:
cf r2 objects bulk-delete --bucket-name <bucket> --prefix "some/path/" --force
┌ Error
│ --body is required for this command. Pass --body '<json>' or --body @path/to/file.json.
Without --force in a non-interactive shell, it prints the confirmation and (non-interactive; pass --force to confirm), then Aborted., so the body error only shows once --force is added.
Workaround that worked for us: list the keys with cf r2 objects list --bucket-name <bucket> --prefix <p> and delete each with cf r2 objects delete --bucket-name <bucket> <key> --force.
Activity
vaibhavmule commentedon Oct 1, 2026
Still reproduces on cf 1.0.0-beta.10 (macOS, Node 24.3.0), and with a non-empty prefix too, not only
--prefix=:Without
--forcein a non-interactive shell, it prints the confirmation and(non-interactive; pass --force to confirm), thenAborted., so the body error only shows once--forceis added.Workaround that worked for us: list the keys with
cf r2 objects list --bucket-name <bucket> --prefix <p>and delete each withcf r2 objects delete --bucket-name <bucket> <key> --force.