vectordotdev/vector · error

Invalid config file name

Error message

Invalid config file name

What it means

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.

Solutions

  1. Rename the config file to a UTF-8-safe name (plain ASCII, e.g. vector.yaml) and rerun the command.
  2. Check the path with `echo <path> | iconv -f utf-8 -t utf-8` to confirm it is valid UTF-8.
  3. 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: {:?}".
  4. Use Path::display() or to_string_lossy only for messages, never for passing the path; prefer passing OsStr directly where the API allows.

Example fix

// before
"--config",
self.config.to_str().expect("Invalid config file name"),
// after
"--config",
self.config.to_str().ok_or_else(|| anyhow!(
    "config path is not valid UTF-8: {}", self.config.display()
))?,
Defensive patterns

Strategy: validation

Validate before calling

// before running vdev
import unicodedata
path = sys.argv[1]
assert path.isascii() or path.encode('utf-8').decode('utf-8') == path, "config path must be UTF-8"

Type guard

fn is_utf8_path(p: &Path) -> bool { p.to_str().is_some() }

Try / catch

match self.config.to_str() {
    Some(s) => /* use s */,
    None => return Err(anyhow!("config path is not valid UTF-8: {}", self.config.display())),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/ff9b396c95986a2a. Report an issue: GitHub.

Appendix: source

Thrown at vdev/src/commands/run.rs:51

        let mut features = features::load_and_extract(&self.config)?;
        features.extend(self.feature);
        let features = features.join(",");
        let mut command = Command::new("cargo");
        command.args([
            "run",
            "--package",
            "vector",
            "--no-default-features",
            "--features",
            &features,
        ]);
        if self.release {
            command.arg("--release");
        }
        command.args([
            "--",
            "--config",
            self.config.to_str().expect("Invalid config file name"),
        ]);
        command.args(self.args);
        command.check_run()
    }
}

View on GitHub (pinned to bdb87aeaa4)