Hmbown/CodeWhale · error
config path cannot be empty
Error message
config path cannot be empty
What it means
normalize_config_file_path validates a user-supplied config file path before resolving it against the current directory. An empty path (PathBuf::from("") or whitespace-equivalent OS string) cannot name a file, so the library rejects it immediately. This fails loud at the earliest point per the repository's misconfiguration rule.
Solutions
- Pass an actual path to the config file, e.g. "/home/user/.config/codewhale/config.toml"
- Check the env var / CLI flag source for an empty value before calling the loader
- If the default config should be used, omit the path argument instead of passing ""
Example fix
// before
let path = std::env::var("CODEWHALE_CONFIG").unwrap_or_default();
load_config(PathBuf::from(path))
// after
let path = std::env::var("CODEWHALE_CONFIG")
.ok()
.filter(|p| !p.is_empty())
.map(PathBuf::from)
.unwrap_or_else(default_config_path); Defensive patterns
Strategy: validation
Validate before calling
fn usable_config_path(p: &std::path::Path) -> bool {
!p.as_os_str().is_empty() && p.file_name().is_some()
} Type guard
fn non_empty_path(p: &str) -> Option<std::path::PathBuf> {
if p.trim().is_empty() { None } else { Some(std::path::PathBuf::from(p)) }
} Try / catch
match normalize_config_file_path(path) {
Ok(p) => p,
Err(e) if e.to_string().contains("config path cannot be empty") => {
eprintln!("--config was empty; using default");
default_config_path()
}
Err(e) => return Err(e),
} Prevention
- Filter empty env-var values before converting to PathBuf
- Quote CLI flags so unset variables fail loudly instead of passing ""
- Default to the standard config location when no explicit path is given
When it happens
Trigger: Calling the config-loading entry point with PathBuf::new(), PathBuf::from(""), or a CLI/env-derived --config value that expanded to an empty string.
Common situations: An unset CONFIG environment variable being read as "", a shell expanding an unquoted empty variable into the --config flag, or code constructing the path by joining an empty base directory.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Codewhale credentials directory must be lexically normalized
- config path cannot contain '..' components
- config path must include a file name
- managed directory path cannot be empty
- persistent path allow rules must stay within the workspace
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/bb4fffbb9546c72a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/config/src/lib.rs:6757
child_key.clone()
} else {
format!("{key}.{child_key}")
};
redacted.insert(
child_key.clone(),
redact_toml_value_for_display_inner(&path, sensitive, child_value),
);
}
toml::Value::Table(redacted)
}
_ if sensitive => toml::Value::String("********".to_string()),
_ => value.clone(),
}
}
fn normalize_config_file_path(path: PathBuf) -> Result<PathBuf> {
if path.as_os_str().is_empty() {
bail!("config path cannot be empty");
}
if path
.components()
.any(|component| matches!(component, Component::ParentDir))
{
bail!("config path cannot contain '..' components");
}
if path.file_name().is_none() {
bail!("config path must include a file name");
}
let absolute = if path.is_absolute() {
path
} else {
std::env::current_dir()
.context("failed to resolve current directory for config path")?
.join(path)
};
let file_name = absoluteView on GitHub (pinned to 73e0f67d83)