{"id":"c9d4b3927309a4ec","repo":"BurntSushi/ripgrep","slug":"stdin-has-no-metadata","errorCode":null,"errorMessage":"<stdin> has no metadata","messagePattern":"<stdin> has no metadata","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ignore/src/walk.rs","lineNumber":176,"sourceCode":"        match *self {\n            Stdin => false,\n            Walkdir(ref x) => x.path_is_symlink(),\n            Raw(ref x) => x.path_is_symlink(),\n        }\n    }\n\n    fn is_stdin(&self) -> bool {\n        match *self {\n            DirEntryInner::Stdin => true,\n            _ => false,\n        }\n    }\n\n    fn metadata(&self) -> Result<Metadata, Error> {\n        use self::DirEntryInner::*;\n        match *self {\n            Stdin => {\n                let err = Error::Io(io::Error::new(\n                    io::ErrorKind::Other,\n                    \"<stdin> has no metadata\",\n                ));\n                Err(err.with_path(\"<stdin>\"))\n            }\n            Walkdir(ref x) => x.metadata().map_err(|err| {\n                Error::Io(io::Error::from(err))\n                    .with_depth(x.depth())\n                    .with_path(x.path())\n            }),\n            Raw(ref x) => x.metadata(),\n        }\n    }\n\n    fn file_type(&self) -> Option<FileType> {\n        use self::DirEntryInner::*;\n        match *self {\n            Stdin => None,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/ignore/src/walk.rs#L158-L194","documentation":"DirEntry::metadata() delegates to DirEntryInner::metadata(); for the Stdin variant it unconditionally returns Err with '<stdin> has no metadata'. Stdin is a synthetic directory entry with no underlying file, so file size/times/permissions are undefined and the API refuses to fabricate them.","triggerScenarios":"Calling DirEntry::metadata() on an entry created from stdin (DirEntry::is_stdin() is true), e.g. when ripgrep searches '-' and downstream code asks for the entry's metadata.","commonSituations":"Custom code iterating WalkBuilder entries that unconditionally calls metadata() without checking is_stdin(); piping data via stdin to a tool that filters by file size.","solutions":["Guard the call: if entry.is_stdin() { /* skip metadata-dependent logic */ } before calling metadata().","Treat the error as expected for stdin entries and fall back to streaming search without size-based heuristics.","When you need size/mtime, require a real file path instead of stdin."],"exampleFix":"// before\nlet md = entry.metadata()?; // errors for stdin\n\n// after\nlet md = if entry.is_stdin() {\n    None\n} else {\n    Some(entry.metadata()?)\n};","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn has_metadata(e: &DirEntry) -> bool { !e.is_stdin() }","tryCatchPattern":"let md = if entry.is_stdin() { None } else { Some(entry.metadata()?) };","preventionTips":["Always check DirEntry::is_stdin() before calling metadata().","Design size/mtime-based filters to no-op for stdin entries.","Document that stdin entries have no metadata in your tool's help text."],"tags":["walk","stdin","metadata","ignore"],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}