Skip to content

fix(curl): inherit stdin so -d @- / -T - / --data-binary @- work (fixes #4084) - #4370

Closed
TechWizard9999 wants to merge 2 commits into
rtk-ai:developfrom
TechWizard9999:fix/4084-curl-stdin-inherit
Closed

TechWizard9999 wants to merge 2 commits into
rtk-ai:developfrom
TechWizard9999:fix/4084-curl-stdin-inherit

Conversation

@TechWizard9999

Copy link
Copy Markdown
Contributor

Summary

Fixes #4084: rtk curl -d @- (and -T -, --data-binary @-, -F field=@-, -K -) sends an empty body because the child process gets an immediate-EOF stdin.

Root Cause

curl_cmd::run() spawns curl via cmd.output() without configuring stdin. Per std's documented behavior, output() gives the child an immediate-EOF stdin. curl's @- forms read from stdin, so they receive EOF → empty body.

Fix

Added cmd.stdin(std::process::Stdio::inherit()) before cmd.output() in curl_cmd::run(). This mirrors the existing pattern in npm_cmd.rs / wc_cmd.rs (RunOptions::inherit_stdin()).

Covers all stdin-reading forms: -d @-, -T -, --data-binary @-, -F field=@-, -K -.

Testing

  • Existing 15 filter/binary tests in curl_cmd.rs still pass
  • Verified the fix manually: echo '{"test":1}' | rtk curl -d @- ... now sends the body instead of LEN=0
  • Follow-up: add integration test with an echo server (follow-up issue)

Without stdin inheritance, cmd.output() gives the child an immediate-EOF stdin,
causing curl to read an empty body for -d @-, -T -, --data-binary @-, -F field=@-, -K -.
This mirrors the existing pattern in npm_cmd.rs / wc_cmd.rs (RunOptions::inherit_stdin).

Fixes rtk-ai#4084.
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added area:cli bug Something isn't working labels Oct 1, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk curl dropping request bodies when using stdin-reading forms like -d @-, -T -, --data-binary @-, -F field=@-, or -K -. The root cause was that cmd.output() gives the child process immediate-EOF stdin, so the fix adds cmd.stdin(Stdio::inherit()) before spawning curl, mirroring the existing pattern in npm_cmd.rs and wc_cmd.rs.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4084


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

Hi @KuSh , Could you please review this ?

@KuSh

KuSh commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Thanks for picking this up, @TechWizard9999. #4085 makes the same change (cmd.stdin(Stdio::inherit()) before cmd.output()), was opened on 2026-09-15 by the reporter of #4084, and adds an integration test with an in-process HTTP server that fails without the line and passes with it. I ran both heads against an echo server: they behave identically on -d @-, --data-binary @-, -T -, -F field=@- and -K -, where develop sends an empty body on all of them. Closing this one as a duplicate; the review continues on #4085.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk curl drops the request body passed on stdin (-d @-)

2 participants