{"record":{"id":"ff9b396c95986a2a","repo":"vectordotdev/vector","slug":"invalid-config-file-name","errorCode":null,"errorMessage":"Invalid config file name","messagePattern":"Invalid config file name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/commands/run.rs","lineNumber":51,"sourceCode":"        let mut features = features::load_and_extract(&self.config)?;\n        features.extend(self.feature);\n        let features = features.join(\",\");\n        let mut command = Command::new(\"cargo\");\n        command.args([\n            \"run\",\n            \"--package\",\n            \"vector\",\n            \"--no-default-features\",\n            \"--features\",\n            &features,\n        ]);\n        if self.release {\n            command.arg(\"--release\");\n        }\n        command.args([\n            \"--\",\n            \"--config\",\n            self.config.to_str().expect(\"Invalid config file name\"),\n        ]);\n        command.args(self.args);\n        command.check_run()\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":57,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/commands/run.rs#L33-L57","documentation":"vdev's run command passes the --config path to cargo/Vector via self.config.to_str().expect(\"Invalid config file name\"). PathBuf::to_str returns None when the path contains invalid UTF-8 (not possible on typical Unix tooling, but possible with unusual filenames/encodings), and this expect panics instead of reporting a friendly error. It guards a path supplied by the CLI user or derived config resolution.","triggerScenarios":"Running `cargo vdev run <config>` where the config file's path contains non-UTF-8 bytes (e.g. Latin-1 encoded filename created by another tool), causing to_str() to return None.","commonSituations":"Config file created or renamed by a script that wrote raw bytes; filesystem with non-UTF-8 locale; copying a path with special characters into the vdev command.","solutions":["Rename the config file to a UTF-8-safe name (plain ASCII, e.g. vector.yaml) and rerun the command.","Check the path with `echo <path> | iconv -f utf-8 -t utf-8` to confirm it is valid UTF-8.","In code, replace the expect with proper handling: match self.config.to_str() and return a anyhow error like \"config path must be valid UTF-8: {:?}\".","Use Path::display() or to_string_lossy only for messages, never for passing the path; prefer passing OsStr directly where the API allows."],"exampleFix":"// before\n\"--config\",\nself.config.to_str().expect(\"Invalid config file name\"),\n// after\n\"--config\",\nself.config.to_str().ok_or_else(|| anyhow!(\n    \"config path is not valid UTF-8: {}\", self.config.display()\n))?,","handlingStrategy":"validation","validationCode":"// before running vdev\nimport unicodedata\npath = sys.argv[1]\nassert path.isascii() or path.encode('utf-8').decode('utf-8') == path, \"config path must be UTF-8\"","typeGuard":"fn is_utf8_path(p: &Path) -> bool { p.to_str().is_some() }","tryCatchPattern":"match self.config.to_str() {\n    Some(s) => /* use s */,\n    None => return Err(anyhow!(\"config path is not valid UTF-8: {}\", self.config.display())),\n}","preventionTips":["Name config files with ASCII characters only.","Avoid renaming config files with non-UTF-8 tools or locales.","Validate paths passed to scripts with `iconv -f utf-8 -t utf-8`.","Keep shell locale set to a UTF-8 variant (e.g. C.UTF-8)."],"tags":["rust","vdev","cli","pathbuf","utf-8","panic"],"backgroundTag":"invalid-cli-argument","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}