{"record":{"id":"fcc41c4bc507b237","repo":"can1357/oh-my-pi","slug":"path-idx-invalid-zero-length-file-name","errorCode":null,"errorMessage":"{path}:{idx}: invalid zero-length file name","messagePattern":"(.+?):(.+?): invalid zero-length file name","errorType":"error_code","errorClass":"WcError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/wc.rs","lineNumber":791,"sourceCode":"impl TotalWhen {\n\tfn is_total_row_visible(self, num_inputs: usize) -> bool {\n\t\tmatch self {\n\t\t\tSelf::Auto => num_inputs > 1,\n\t\t\tSelf::Always | Self::Only => true,\n\t\t\tSelf::Never => false,\n\t\t}\n\t}\n}\n\n#[derive(Debug, Error)]\nenum WcError {\n\t#[error(\"extra operand {}\\nfile operands cannot be combined with --files0-from\", extra.quote())]\n\tFilesDisabled { extra: Cow<'static, OsStr> },\n\t#[error(\"when reading file names from standard input, no file name of '-' allowed\")]\n\tStdinReprNotAllowed,\n\t#[error(\"invalid zero-length file name\")]\n\tZeroLengthFileName,\n\t#[error(\"{path}:{idx}: invalid zero-length file name\")]\n\tZeroLengthFileNameCtx { path: Cow<'static, str>, idx: usize },\n\t#[error(\"{context}: {source}\")]\n\tIo {\n\t\tcontext: String,\n\t\t#[source]\n\t\tsource:  io::Error,\n\t},\n}\n\nimpl WcError {\n\tfn zero_len(ctx: Option<(&Input, usize)>) -> Self {\n\t\tmatch ctx {\n\t\t\tSome((input, idx)) => {\n\t\t\t\tlet path = match input {\n\t\t\t\t\tInput::Stdin(_) => STDIN_REPR.into(),\n\t\t\t\t\tInput::Path(path) => escape_name_wrapper(path.as_os_str()).into(),\n\t\t\t\t};\n\t\t\t\tSelf::ZeroLengthFileNameCtx { path, idx }","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/wc.rs#L773-L809","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// message: list.txt:42: invalid zero-length file name\n// after: inspect and rebuild the list\ntr '\\0' '\\n' < list.txt | sed '42d' | tr '\\n' '\\0' > list.fixed\nwc --files0-from=list.fixed","handlingStrategy":"validation","validationCode":"fn find_empty_records(bytes: &[u8]) -> Vec<usize> {\n    bytes.split(|&b| b == 0)\n        .enumerate()\n        .filter(|(_, s)| s.is_empty())\n        .map(|(i, _)| i)\n        .collect()\n}\n// if !find_empty_records(&list).is_empty() { fix the list before invoking wc }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["wc","files0-from","input-validation","diagnostics"],"backgroundTag":"empty-file-name-in-input","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}