{"record":{"id":"db5fcedfca6d9d55","repo":"run-llama/liteparse","slug":"no-data-on-stdin-input-expects-a-document-pip-db5fce","errorCode":null,"errorMessage":"no data on stdin (input `-` expects a document piped in, e.g. `curl … | lit parse -`)","messagePattern":"no data on stdin \\(input `-` expects a document piped in, e\\.g\\. `curl … \\| lit parse -`\\)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/liteparse/src/main.rs","lineNumber":362,"sourceCode":"        \"text\" => Ok(OutputFormat::Text),\n        \"markdown\" | \"md\" => Ok(OutputFormat::Markdown),\n        _ => Err(format!(\n            \"unknown format '{}', expected 'json', 'text', or 'markdown'\",\n            s\n        )),\n    }\n}\n\n/// Parse a `Name: Value` header string into a `(name, value)` pair.\n/// Read all bytes from stdin, used when the input path is `-` (e.g. a piped\n/// document: `curl -sL … | lit parse -`). Errors carry a hint so a common\n/// mistake — passing `-` with nothing piped — is diagnosable.\nfn read_stdin_bytes() -> Result<Vec<u8>, std::io::Error> {\n    use std::io::Read;\n    let mut bytes = Vec::new();\n    std::io::stdin().lock().read_to_end(&mut bytes)?;\n    if bytes.is_empty() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::UnexpectedEof,\n            \"no data on stdin (input `-` expects a document piped in, e.g. `curl … | lit parse -`)\",\n        ));\n    }\n    Ok(bytes)\n}\n\nfn parse_header(s: &str) -> Result<(String, String), String> {\n    let (name, value) = s\n        .split_once(':')\n        .ok_or_else(|| format!(\"invalid header '{}', expected 'Name: Value'\", s))?;\n    let name = name.trim();\n    if name.is_empty() {\n        return Err(format!(\"invalid header '{}', empty header name\", s));\n    }\n    Ok((name.to_string(), value.trim().to_string()))\n}\n","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/liteparse/src/main.rs#L344-L380","documentation":"The core Rust CLI binary reads the full document from stdin when the input argument is `-`, and returns an `UnexpectedEof` io::Error if nothing was piped in. The dedicated error message makes the common mistake — passing `-` with no piped input — immediately diagnosable instead of failing later in the parser.","triggerScenarios":"Invoking the `liteparse` CLI with `-` as the input path while stdin is empty: interactive terminal invocation with no pipe, a dead/silent upstream producer (`curl` failing silently), or stdin redirected from an empty file.","commonSituations":"CI scripts where an upstream download step produced no output, shell examples pasted without the curl part, scripts reading from a FIFO that closed with no writes.","solutions":["Pipe a real document: `curl -sL <url> | lit parse -`","Enable pipefail so upstream failures abort before the CLI runs: `set -euo pipefail`","Pass a file path directly instead of `-` when the document is on disk","Confirm the producer emitted bytes (`wc -c`) before piping"],"exampleFix":"// before\nlit parse - < /dev/null\n// after\nset -euo pipefail\ncurl -fsSL \"$URL\" | lit parse -","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nset -euo pipefail\ncurl -fsSL \"$URL\" | lit parse -   # -f fails on HTTP errors; pipefail propagates","typeGuard":null,"tryCatchPattern":"if ! out=$(curl -fsSL \"$URL\"); then\n  echo \"download failed\" >&2; exit 1\nfi\nprintf '%s' \"$out\" | lit parse -","preventionTips":["Enable `set -euo pipefail` in scripts that pipe into the CLI","Verify the producer emits bytes (`wc -c`) before piping","Pass a real file path instead of `-` whenever possible","Check the upstream tool's exit status and logs when the CLI reports empty stdin"],"tags":["cli","stdin","rust","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}