Skip to content

fix: allow bodyless non-GET requests in api request rest - #270

Merged
soridalac merged 1 commit into
salesforcecli:mainfrom
stijnhoste:fix/rest-bodyless-delete
Nov 30, 2026
Merged

soridalac merged 1 commit into
salesforcecli:mainfrom
stijnhoste:fix/rest-bodyless-delete

Conversation

@stijnhoste

Copy link
Copy Markdown
Contributor

Fixes forcedotcom/cli#3693

What

sf api request rest -X DELETE <url> (or any non-GET request) with no --body and no --file threw No 'mode' found in 'body' entry and never sent the request. The documented empty body, --body "", failed the same way.

This happened because the last branch of the body logic always called getBodyContents(fileOptions?.body). That runs even when there's no --file, and when --body is "", which is falsy.

Change

  • Only read the body from --file when --body isn't given and the file has a body.
  • Otherwise, send no body.
  • A --file body that's present but has no mode still raises the existing error.

Tests

  • New unit tests: a DELETE with no --body/--file, and a DELETE with --body "". Both expect a bodyless request.
  • Both tests fail on main with the reported error and pass with this change.
  • yarn build, yarn lint and yarn test:only pass (22 passing).

🤖 Generated with Claude Code

A DELETE (or any non-GET request) with no --body and no --file threw
"No 'mode' found in 'body' entry" before sending, and so did the
documented empty body --body "". Only read the body from --file when
the file has one; otherwise send no body.

Fixes forcedotcom/cli#3693

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@soridalac
soridalac merged commit c7f515c into salesforcecli:main Nov 30, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: sf api request rest -X DELETE fails with "No 'mode' found in 'body' entry" when no --file is given (also with --body "")

2 participants