{"record":{"id":"7bedb06259f7229b","repo":"quickwit-oss/quickwit","slug":"invalid-file-name-in-path-path","errorCode":null,"errorMessage":"Invalid file name in path {path:?}","messagePattern":"Invalid file name in path (.+?)","errorType":"validation","errorClass":"io::Error (InvalidData)","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-storage/src/split.rs","lineNumber":186,"sourceCode":"        Ok(offsets)\n    }\n\n    /// Adds the payload to the bundle file.\n    pub fn add_payload(&mut self, file_name: String, payload: Box<dyn PutPayload>) {\n        let range = self.current_offset as u64..self.current_offset as u64 + payload.len();\n        self.current_offset += payload.len() as usize;\n        self.payloads.push((file_name, payload, range));\n    }\n\n    /// Adds the file to the bundle file.\n    pub fn add_file(&mut self, path: &Path) -> io::Result<()> {\n        let file = std::fs::metadata(path)?;\n        let file_name = path\n            .file_name()\n            .and_then(std::ffi::OsStr::to_str)\n            .map(ToOwned::to_owned)\n            .ok_or_else(|| {\n                io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    format!(\"Invalid file name in path {path:?}\"),\n                )\n            })?;\n\n        let file_payload = FilePayload {\n            path: path.to_owned(),\n            len: file.len(),\n        };\n\n        self.add_payload(file_name, Box::new(file_payload));\n\n        Ok(())\n    }\n\n    /// Writes the bundle file ranges at the end of the bundle file.\n    pub fn finalize(self, hotcache: &[u8]) -> anyhow::Result<SplitPayload> {\n        let enable_footer_trailer =","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-storage/src/split.rs#L168-L204","documentation":"When building a FilePayload, the code takes a filesystem path and extracts its final path component as the upload file name. If the path has no file name — e.g. it ends in '..' or is a bare root like '/' — `path.file_name()` returns None and this io::Error with ErrorKind::InvalidData is constructed. It is an internal guard: callers of add_file are expected to pass concrete file paths, not directories or traversal components.","triggerScenarios":"Calling add_file (via get_split_payload) with a path whose last component is not a regular file name: a trailing slash or '..' component, a path like \"/\" or \"/tmp/..\", or a non-UTF-8 final component (OsStr::to_str fails).","commonSituations":"Building split payloads from programmatically joined paths where a directory was passed instead of the hotcache/anchor file inside it; shell/script variable expansions leaving a trailing slash; non-UTF-8 filenames on Linux.","solutions":["Pass the full path to a concrete file (e.g. <split_dir>/hotcache) rather than its parent directory.","Strip trailing slashes and resolve '..' components before calling add_file (use PathBuf::canonicalize).","Ensure the path is valid UTF-8 on Unix (or rename the file) since file_name() must convert via OsStr::to_str."],"exampleFix":"// before\nadd_file(&split_dir.join(\"..\")).await?;\n// after\nlet hotcache_path = split_dir.canonicalize()?.join(\"hotcache\");\nadd_file(&hotcache_path).await?;","handlingStrategy":"validation","validationCode":"let path = PathBuf::from(raw);\nassert!(path.file_name().is_some(), \"path must end in a real file name: {raw:?}\");\nlet path = path.canonicalize()?;","typeGuard":"fn has_file_name(path: &Path) -> bool { path.file_name().map(|n| n.to_str().is_some()).unwrap_or(false) }","tryCatchPattern":null,"preventionTips":["Always append the concrete file name (hotcache, etc.) to split directories before building payloads.","Canonicalize paths to remove '..' and trailing-slash artifacts.","Keep file names ASCII/UTF-8 on Linux volumes."],"tags":["storage","path","io"],"backgroundTag":"invalid-argument-format","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}