{"record":{"id":"f3d73d2650ef2077","repo":"can1357/oh-my-pi","slug":"no-input-from","errorCode":null,"errorMessage":"no input from {}","messagePattern":"no input from (.+?)","errorType":"exception","errorClass":"SortError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/sort.rs","lineNumber":2627,"sourceCode":"\tCompressProgExecutionFailed { prog: String, error: std::io::Error },\n\n\t#[error(\"{} terminated abnormally\", .prog.quote())]\n\tCompressProgTerminatedAbnormally { prog: String },\n\n\t#[error(\"cannot create temporary file in {}:\", .path.quote())]\n\tTmpFileCreationFailed { path: PathBuf },\n\n\t#[error(\"extra operand {}\\nfile operands cannot be combined with --files0-from\\nTry 'sort --help' for more information.\", .file.quote())]\n\tFileOperandsCombined { file: PathBuf },\n\n\n\t#[error(\"multiple output files specified\")]\n\tMultipleOutputFiles,\n\n\t#[error(\"when reading file names from standard input, no file name of '-' allowed\")]\n\tMinusInStdIn,\n\n\t#[error(\"no input from {}\", .file.quote())]\n\tEmptyInputFile { file: PathBuf },\n\n\t#[error(\"{}:{}: invalid zero-length file name\", .file.maybe_quote(), .line_num)]\n\tZeroLengthFileName { file: PathBuf, line_num: usize },\n}\n\nimpl SortError {\n\tfn message(message: impl Into<String>) -> Self {\n\t\tSelf::Message(message.into())\n\t}\n\n\tfn code(&self) -> i32 {\n\t\tif matches!(self, Self::Disorder { .. }) { 1 } else { 2 }\n\t}\n}\n\n// refs are required because this fn is used by thiserror macro\n#[expect(clippy::trivially_copy_pass_by_ref)]","sourceCodeStart":2609,"sourceCodeEnd":2645,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/sort.rs#L2609-L2645","documentation":"SortError::EmptyInputFile (\"no input from ...\") is thrown when an input file the sort builtin was asked to read exists but yields no data — e.g. it is an empty regular file or cannot provide any input — so sort reports there is 'no input' from that file. The offending file path is included quoted.","triggerScenarios":"Running sort on a zero-byte file: `sort empty.txt`; a truncated download/log that is 0 bytes; a file whose contents vanished between listing and reading (race with deletion/rotation).","commonSituations":"Pipelines where an upstream producer wrote nothing (failed producer, grep matched nothing redirected to a file); log rotation emptying files mid-run; batch scripts sorting many files where some are legitimately empty.","solutions":["Check the file is non-empty before sorting: `[ -s \"$f\" ]` in shell or `fs.metadata().size > 0` programmatically.","Skip empty inputs in the caller's file loop.","If empty input should be tolerated, handle it upstream (e.g. `sort f 2>/dev/null || true`) or supply a fallback input.","Investigate why the producer of that file wrote nothing if emptiness is unexpected."],"exampleFix":"// before: sort each file unconditionally\nfor f in *.txt; do sort \"$f\" -o \"$f.sorted\"; done\n// after: skip empty files\nfor f in *.txt; do [ -s \"$f\" ] && sort \"$f\" -o \"$f.sorted\"; done","handlingStrategy":"validation","validationCode":"import { statSync } from \"node:fs\";\n// skip zero-byte files before sorting\nconst sortable = files.filter(f => statSync(f).size > 0);","typeGuard":"const isNonEmptyFile = (path: string): boolean => {\n  try { return statSync(path).size > 0; } catch { return false; }\n};","tryCatchPattern":"try {\n  await sort([file]);\n} catch (err) {\n  if (String(err).startsWith(\"no input from\")) {\n    // tolerate legitimately empty inputs\n    logger.warn(\"skipping empty input\", { file });\n  } else throw err;\n}","preventionTips":["Check file size (-s / statSync().size) before sorting user-facing inputs.","Verify upstream producers actually wrote data before consuming their outputs.","Handle log-rotation races by re-stat'ing or reopening files.","Decide and document policy for empty inputs in batch sort jobs."],"tags":["sort","empty-file","io","input-validation"],"backgroundTag":"empty-input-file","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}