can1357/oh-my-pi · error · SortError
no input from {}
Error message
no input from {} What it means
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.
Source
Thrown at crates/pi-builtins/src/sort.rs:2627
CompressProgExecutionFailed { prog: String, error: std::io::Error },
#[error("{} terminated abnormally", .prog.quote())]
CompressProgTerminatedAbnormally { prog: String },
#[error("cannot create temporary file in {}:", .path.quote())]
TmpFileCreationFailed { path: PathBuf },
#[error("extra operand {}\nfile operands cannot be combined with --files0-from\nTry 'sort --help' for more information.", .file.quote())]
FileOperandsCombined { file: PathBuf },
#[error("multiple output files specified")]
MultipleOutputFiles,
#[error("when reading file names from standard input, no file name of '-' allowed")]
MinusInStdIn,
#[error("no input from {}", .file.quote())]
EmptyInputFile { file: PathBuf },
#[error("{}:{}: invalid zero-length file name", .file.maybe_quote(), .line_num)]
ZeroLengthFileName { file: PathBuf, line_num: usize },
}
impl SortError {
fn message(message: impl Into<String>) -> Self {
Self::Message(message.into())
}
fn code(&self) -> i32 {
if matches!(self, Self::Disorder { .. }) { 1 } else { 2 }
}
}
// refs are required because this fn is used by thiserror macro
#[expect(clippy::trivially_copy_pass_by_ref)]View on GitHub (pinned to 9690622007)
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.
Example fix
// before: sort each file unconditionally for f in *.txt; do sort "$f" -o "$f.sorted"; done // after: skip empty files for f in *.txt; do [ -s "$f" ] && sort "$f" -o "$f.sorted"; done
Defensive patterns
Strategy: validation
Validate before calling
import { statSync } from "node:fs";
// skip zero-byte files before sorting
const sortable = files.filter(f => statSync(f).size > 0); Type guard
const isNonEmptyFile = (path: string): boolean => {
try { return statSync(path).size > 0; } catch { return false; }
}; Try / catch
try {
await sort([file]);
} catch (err) {
if (String(err).startsWith("no input from")) {
// tolerate legitimately empty inputs
logger.warn("skipping empty input", { file });
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- dates before 1970 are unsupported
- write failed: {}: {}
- open failed: {}: {}
- cannot read: {}: {}
- failed to open temporary file: {}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/f3d73d2650ef2077.
Report an issue: GitHub.