{"record":{"id":"aad44eb371609ce6","repo":"run-llama/liteparse","slug":"no-data-on-stdin-input-expects-a-document-pip","errorCode":null,"errorMessage":"no data on stdin (input `-` expects a document piped in, e.g. `curl … | liteparse parse -`)","messagePattern":"no data on stdin \\(input `-` expects a document piped in, e\\.g\\. `curl … \\| liteparse parse -`\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/node/src/cli.ts","lineNumber":28,"sourceCode":"  .name(\"liteparse\")\n  .description(\"Fast, lightweight PDF and document parsing\")\n  .version(\"2.0.0\");\n\n/**\n * Resolve a CLI `<file>` argument into a parser input. `-` means read the\n * document from stdin (e.g. `curl -sL … | liteparse parse -`); anything else is\n * passed through as a path. Streaming stdin (rather than `readFileSync(0)`)\n * avoids EAGAIN on non-blocking pipes.\n */\nasync function resolveInput(file: string): Promise<string | Buffer> {\n  if (file !== \"-\") return file;\n  const chunks: Buffer[] = [];\n  for await (const chunk of process.stdin) {\n    chunks.push(chunk as Buffer);\n  }\n  const bytes = Buffer.concat(chunks);\n  if (bytes.length === 0) {\n    throw new Error(\n      \"no data on stdin (input `-` expects a document piped in, e.g. `curl … | liteparse parse -`)\",\n    );\n  }\n  return bytes;\n}\n\n/** Collect repeated `--ocr-server-header \"Name: Value\"` flags into an object. */\nfunction collectHeader(\n  value: string,\n  previous: Record<string, string> = {},\n): Record<string, string> {\n  const idx = value.indexOf(\":\");\n  if (idx === -1) {\n    throw new Error(`invalid header '${value}', expected 'Name: Value'`);\n  }\n  const name = value.slice(0, idx).trim();\n  if (name === \"\") {\n    throw new Error(`invalid header '${value}', empty header name`);","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/node/src/cli.ts#L10-L46","documentation":"LiteParse throws this when the CLI input is `-` (stdin) but nothing was piped in. The CLI reads all of process.stdin and, if zero bytes arrive, it cannot distinguish 'closed with no data' from 'forgot to pipe', so it fails with guidance showing the expected pipe usage. It exists to fail fast with an actionable message instead of parsing an empty document.","triggerScenarios":"Running `liteparse parse -` or `liteparse stats -` without piping any bytes into stdin, e.g. running it interactively in a terminal and pressing Ctrl+D immediately, or a shell script where the upstream command in the pipe produced no output.","commonSituations":"CI jobs where the curl/wget step failed silently upstream; forgetting the `|` and running `liteparse parse -` directly; piping from a file that is empty; copy-pasting a documented example without the `curl ... |` prefix.","solutions":["Pipe an actual document into the command: `curl -s https://example.com/doc.pdf | liteparse parse -`.","If you meant a file on disk, pass the path instead of `-`: `liteparse parse ./doc.pdf`.","Check that the upstream command in the pipeline actually succeeded and emitted bytes (`set -o pipefail` in bash helps surface upstream failures)."],"exampleFix":"// before\nliteparse parse -\n// after\ncurl -s https://example.com/doc.pdf | liteparse parse -","handlingStrategy":"validation","validationCode":"const isTTY = process.stdin.isTTY;\nif (process.argv.includes('-') && isTTY) {\n  console.error('input `-` requires piped stdin, e.g. curl ... | liteparse parse -');\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await cli.parseAsync();\n} catch (e) {\n  if (e.message.includes('no data on stdin')) {\n    console.error('Nothing was piped in. Usage: curl -s <url> | liteparse parse -');\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Never run the CLI interactively with `-`; always pipe a real document.","Use `set -o pipefail` in bash scripts so an empty upstream pipe fails the job visibly.","Prefer explicit file paths over `-` unless streaming is required."],"tags":["cli","stdin","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"}