{"record":{"id":"5c815a64ac68778f","repo":"run-llama/liteparse","slug":"no-data-on-stdin-input-expects-a-document-pip-5c815a","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-python/src/cli.rs","lineNumber":262,"sourceCode":"    match s.to_lowercase().as_str() {\n        \"off\" | \"none\" => Ok(ImageMode::Off),\n        \"placeholder\" => Ok(ImageMode::Placeholder),\n        \"embed\" => Ok(ImageMode::Embed),\n        _ => Err(format!(\n            \"unknown image-mode '{}', expected 'off', 'placeholder', or 'embed'\",\n            s\n        )),\n    }\n}\n\n/// Read all bytes from stdin, used when the input path is `-` (e.g. a piped\n/// document: `curl -sL … | lit parse -`).\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\n/// Run the CLI with the given args (typically from sys.argv).\npub fn run_cli(args: Vec<String>) -> Result<(), Box<dyn std::error::Error>> {\n    let cli = Cli::parse_from(args);\n    let rt = tokio::runtime::Runtime::new()?;\n\n    match cli.command {\n        Commands::Parse(cmd) => {\n            let format = parse_output_format(&cmd.format)?;\n            let image_mode = parse_image_mode(&cmd.image_mode)?;\n            let mut config = LiteParseConfig {\n                ocr_language: cmd.ocr_language,","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/crates/liteparse-python/src/cli.rs#L244-L280","documentation":"The Python-binding CLI (`lit` from the PyPI/native package) reads the whole document from stdin when the input argument is `-`, and raises `UnexpectedEof` if zero bytes were received. This guards against running `lit parse -` in a terminal with nothing piped in, which would otherwise produce a confusing parser failure. The message explicitly shows the expected usage pattern.","triggerScenarios":"Running `lit parse -` (or equivalent subcommand with `-` as input) without piping any data: bare invocation in a terminal, a failed/silent upstream command in the pipe (e.g. `curl` returned nothing), or stdin redirected from an empty file (`< empty.pdf`).","commonSituations":"Copy-pasting the `curl … | lit parse -` example where curl failed or printed an error page to stderr only, forgetting the pipe and typing the command interactively, or an empty file produced by a failed download.","solutions":["Pipe actual document bytes: `curl -sL https://example.com/doc.pdf | lit parse -`","Check the upstream command's exit status before the pipe (`set -o pipefail` in bash)","If the document is on disk, pass the file path directly instead of `-`","Verify the source URL/file actually contains data (`curl -sL <url> | wc -c`)"],"exampleFix":"// before\nlit parse -\n// after\ncurl -fsSL https://example.com/report.pdf | lit parse -\n# or, from a file:\nlit parse ./report.pdf","handlingStrategy":"validation","validationCode":"# before running: lit parse -\ndata=$(curl -fsSL \"$URL\" | tee /dev/stderr | wc -c)\n[ \"$data\" -gt 0 ] || { echo \"upstream produced no data\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! curl -fsSL \"$URL\" | lit parse -; then\n  echo \"pipe failed: check curl output/exit status\" >&2\nfi\n# with pipefail:\nset -o pipefail","preventionTips":["Use `set -o pipefail` so a failed upstream command is not swallowed","Prefer passing a file path directly when the document is already on disk","Use `curl -f` so HTTP errors produce a nonzero exit instead of empty output","Avoid typing `lit parse -` interactively; `-` is only for piped input"],"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"}