vectordotdev/vector · error
Invalid filename
Error message
Invalid filename {} What it means
`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.
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.
Example fix
// before: examples dir contains a file with invalid UTF-8 name // after mv "config/$(ls config | grep -v '^[a-z0-9_.-]*$')" config/renamed_example.yaml
Defensive patterns
Strategy: validation
Validate before calling
for entry in std::fs::read_dir("config")? {
let p = entry?.path();
if p.as_os_str().to_str().is_none() { eprintln!("non-UTF-8 filename: {p:?}"); }
} Type guard
fn has_utf8_name(p: &Path) -> bool { p.as_os_str().to_str().is_some() } Prevention
- Do not create oddly-named scratch files inside the examples directory.
- Clean up test artifacts before committing.
- Use only ASCII filenames for config examples.
When it happens
Trigger: 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`.
Common situations: Stray files with unusual names created by test runs, editors, or copied from another OS ending up in `config/` examples directory.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- already exists
- does not exist
- Failed to get metadata for
- failed to read path
- failed to turn path into string
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/732dde987fedaca4.
Report an issue: GitHub.
Appendix: source
Thrown at vdev/src/commands/check/examples.rs:24
/// Check that the config/example files are valid
#[derive(clap::Args, Debug)]
#[command()]
pub struct Cli {}
const EXAMPLES: &str = "config/examples";
impl Cli {
pub fn exec(self) -> Result<()> {
app::set_repo_dir()?;
for entry in fs::read_dir(EXAMPLES)
.with_context(|| format!("Could not read directory {EXAMPLES:?}"))?
{
let entry = entry.with_context(|| format!("Could not read entry from {EXAMPLES:?}"))?;
let filename = entry.path();
let Some(filename) = filename.as_os_str().to_str() else {
bail!("Invalid filename {}", filename.display());
};
let mut command = vec![
"run",
"--",
"validate",
"--deny-warnings",
"--no-environment",
];
if entry
.metadata()
.with_context(|| format!("Could not get metadata of {filename:?}"))?
.is_dir()
{
command.push("--config-dir");
}
command.push(filename);
View on GitHub (pinned to bdb87aeaa4)