fj api: read request body from stdin (--input -) or file (--input @path) #136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task
Let
fj apiread its request body from stdin or a file, matchinggh api:--input -reads the body from stdin until EOF.--input @pathreads the body from a file.-F key=@path(gh-style) so a single field is sourced from a file (@-for stdin,@filefor a file), per gh's convention.Keep the existing inline-string behavior for any value that is not
-/@....Source: rasterstate/fj#126.
Priority
p1. Streaming a generated payload into the escape hatch (
jq -n '...' | fj api -X POST .../statuses/$SHA --input -) is the single most commongh apiwrite idiom, andfjhas no equivalent. Theapicommand is the documented fallback for everything fj does not natively model, so a fallback that cannot accept generated/large/metacharacter-bearing payloads is a hard wall for CI, which is why this rates p1.Reason
--inputis parsed only as a literal JSON string (src/cli/api.rs:137):serde_json::from_str(input)with no-/@filehandling here or insplit_kv(:259), and the-f/-Ffield parsers (:143-167) treat every value as literal, so-f body=@payload.jsonsends the literal text@payload.json. The field doc comment even says values are taken verbatim (:40). So any payload generated by another tool, exceeding a comfortable command-line length, or containing shell metacharacters cannot be sent.Acceptance
fj api -X POST <path> --input -reads the request body from stdin.fj api -X POST <path> --input @file.jsonreads the body from a file.-F key=@pathsources a single field from a file;@-from stdin.-/@...keeps today's literal-string behavior.--input must be valid JSONcontext.src/client/integration_tests.rsfor stdin and file body sources.cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --allpass.Dependencies
None. Sibling to rasterstate/fj#124 (
-F/--body-filefor issue/pr/release/milestone prose bodies); this issue is the raw HTTP request body on theapipassthrough. Unblocks thefj apiworkaround called out in rasterstate/fj#127.Size
S