{"record":{"id":"732dde987fedaca4","repo":"vectordotdev/vector","slug":"invalid-filename","errorCode":null,"errorMessage":"Invalid filename {}","messagePattern":"Invalid filename (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/commands/check/examples.rs","lineNumber":24,"sourceCode":"\n/// Check that the config/example files are valid\n#[derive(clap::Args, Debug)]\n#[command()]\npub struct Cli {}\n\nconst EXAMPLES: &str = \"config/examples\";\n\nimpl Cli {\n    pub fn exec(self) -> Result<()> {\n        app::set_repo_dir()?;\n\n        for entry in fs::read_dir(EXAMPLES)\n            .with_context(|| format!(\"Could not read directory {EXAMPLES:?}\"))?\n        {\n            let entry = entry.with_context(|| format!(\"Could not read entry from {EXAMPLES:?}\"))?;\n            let filename = entry.path();\n            let Some(filename) = filename.as_os_str().to_str() else {\n                bail!(\"Invalid filename {}\", filename.display());\n            };\n\n            let mut command = vec![\n                \"run\",\n                \"--\",\n                \"validate\",\n                \"--deny-warnings\",\n                \"--no-environment\",\n            ];\n            if entry\n                .metadata()\n                .with_context(|| format!(\"Could not get metadata of {filename:?}\"))?\n                .is_dir()\n            {\n                command.push(\"--config-dir\");\n            }\n            command.push(filename);\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/commands/check/examples.rs#L6-L42","documentation":"`vdev check examples` iterates the examples directory and requires every entry path to be valid UTF-8 to build a `vector validate` command. If an entry's filename cannot be converted to a Rust `str`, the command bails immediately.","triggerScenarios":"A file inside the examples directory has a non-UTF-8 filename (e.g. created accidentally with weird bytes) so `as_os_str().to_str()` returns `None`.","commonSituations":"Stray files with unusual names created by test runs, editors, or copied from another OS ending up in `config/` examples directory.","solutions":["Find the offending file (its path is printed in the error) with `ls` or `find <examples-dir> -type f`.","Rename it to a normal UTF-8 name or delete it if it is not a real example.","Re-run the check."],"exampleFix":"// before: examples dir contains a file with invalid UTF-8 name\n// after\nmv \"config/$(ls config | grep -v '^[a-z0-9_.-]*$')\" config/renamed_example.yaml\n","handlingStrategy":"validation","validationCode":"for entry in std::fs::read_dir(\"config\")? {\n    let p = entry?.path();\n    if p.as_os_str().to_str().is_none() { eprintln!(\"non-UTF-8 filename: {p:?}\"); }\n}","typeGuard":"fn has_utf8_name(p: &Path) -> bool { p.as_os_str().to_str().is_some() }","tryCatchPattern":null,"preventionTips":["Do not create oddly-named scratch files inside the examples directory.","Clean up test artifacts before committing.","Use only ASCII filenames for config examples."],"tags":["filesystem","encoding","cli"],"backgroundTag":"invalid-argument-format","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"}