can1357/oh-my-pi · error · WcError
{path}:{idx}: invalid zero-length file name
Error message
{path}:{idx}: invalid zero-length file name What it means
WcError::ZeroLengthFileNameCtx is the context-carrying form of the zero-length file name error: `{path}:{idx}: invalid zero-length file name` names the source of the list (path, or stdin) and the 0-based record index, so malformed --files0-from input can be located precisely. It wraps the same condition as ZeroLengthFileName.
Source
Thrown at crates/pi-builtins/src/wc.rs:791
impl TotalWhen {
fn is_total_row_visible(self, num_inputs: usize) -> bool {
match self {
Self::Auto => num_inputs > 1,
Self::Always | Self::Only => true,
Self::Never => false,
}
}
}
#[derive(Debug, Error)]
enum WcError {
#[error("extra operand {}\nfile operands cannot be combined with --files0-from", extra.quote())]
FilesDisabled { extra: Cow<'static, OsStr> },
#[error("when reading file names from standard input, no file name of '-' allowed")]
StdinReprNotAllowed,
#[error("invalid zero-length file name")]
ZeroLengthFileName,
#[error("{path}:{idx}: invalid zero-length file name")]
ZeroLengthFileNameCtx { path: Cow<'static, str>, idx: usize },
#[error("{context}: {source}")]
Io {
context: String,
#[source]
source: io::Error,
},
}
impl WcError {
fn zero_len(ctx: Option<(&Input, usize)>) -> Self {
match ctx {
Some((input, idx)) => {
let path = match input {
Input::Stdin(_) => STDIN_REPR.into(),
Input::Path(path) => escape_name_wrapper(path.as_os_str()).into(),
};
Self::ZeroLengthFileNameCtx { path, idx }View on GitHub (pinned to 9690622007)
Solutions
- Open the list file at the record index reported in the message and remove the empty entry
- Fix the generating command to skip empty inputs before emitting NUL terminators
- Validate the list: `tr '\0' '\n' < list | grep -n '^$'` to find all empty records
- Regenerate the list with `find ... -print0` which never emits empty names
Example fix
// message: list.txt:42: invalid zero-length file name // after: inspect and rebuild the list tr '\0' '\n' < list.txt | sed '42d' | tr '\n' '\0' > list.fixed wc --files0-from=list.fixed
Defensive patterns
Strategy: validation
Validate before calling
fn find_empty_records(bytes: &[u8]) -> Vec<usize> {
bytes.split(|&b| b == 0)
.enumerate()
.filter(|(_, s)| s.is_empty())
.map(|(i, _)| i)
.collect()
}
// if !find_empty_records(&list).is_empty() { fix the list before invoking wc } Prevention
- Pre-validate list files by scanning for empty NUL-delimited records
- Use the reported path:idx from the error to locate and fix the offending record
- Regenerate lists from authoritative sources (find -print0) rather than hand-editing
When it happens
Trigger: Reading file names from a --files0-from file (or stdin) and hitting an empty record at position idx — adjacent NULs in the named list file, or an empty record streamed on stdin.
Common situations: Large generated lists where one producer bug inserted an empty entry; concatenated list files with stray NULs at joins; debugging which record in a huge list is malformed.
Related errors
- invalid zero-length file name
- {}:{}: invalid zero-length file name
- when reading file names from standard input, no file name of
- err.to_string() (timestamp parse error)
- duration is too large: {value}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/fcc41c4bc507b237.
Report an issue: GitHub.