Hmbown/CodeWhale · error · anyhow::Error

failed to parse config at {}; file contents were omitted

Error message

failed to parse config at {}; file contents were omitted

What it means

ConfigStore::load reads the config file and deserializes it into the typed ConfigToml schema. This error means the typed parse failed: the file is either not valid TOML or its values do not match the expected schema (for example a string field holding a table). The underlying toml error and file contents are intentionally dropped so config secrets are not echoed; only the path is quoted.

Source

Thrown at crates/config/src/lib.rs:5007

}

#[derive(Debug, Clone)]
pub struct ConfigStore {
    path: PathBuf,
    pub config: ConfigToml,
    permissions: PermissionsToml,
    /// Original file text, retained so [`save`](Self::save) can merge
    /// comments back after serialisation.
    original_raw: Option<String>,
}

impl ConfigStore {
    pub fn load(path: Option<PathBuf>) -> Result<Self> {
        let path = resolve_config_path(path)?;
        let (config, original_raw) = if checked_path_exists(&path)? {
            let raw = read_checked_config_file(&path)?;
            let mut parsed: ConfigToml = toml::from_str(&raw).map_err(|_| {
                anyhow::anyhow!(
                    "failed to parse config at {}; file contents were omitted",
                    quote_os_path(&path)
                )
            })?;
            let raw_document: toml::Value = toml::from_str(&raw).map_err(|_| {
                anyhow::anyhow!(
                    "failed to parse config at {}; file contents were omitted",
                    quote_os_path(&path)
                )
            })?;
            if let Some(provider_id) = raw_document.get("provider").and_then(toml::Value::as_str) {
                parsed
                    .bind_persisted_provider_id(provider_id)
                    .with_context(|| {
                        format!("failed to parse config at {}", quote_os_path(&path))
                    })?;
            }
            (parsed, Some(raw))

View on GitHub (pinned to 8880682c63)

Solutions

  1. Run a TOML validator or an editor with TOML lint on the file and fix the reported line
  2. Compare the file's structure against config.example.toml shipped in the repository
  3. If the file was written by a much older version, move it aside, let defaults regenerate, and re-add settings incrementally
  4. If the structure matches the example and it still fails, report a bug with the sanitized file

Example fix

# before: YAML syntax pasted into config.toml
model:
  id: glm-4.6

# after: valid TOML
model = "glm-4.6"
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: prove the file is at least well-formed TOML before loading:
fn config_is_well_formed(path: &std::path::Path) -> bool {
    std::fs::read_to_string(path)
        .map(|raw| raw.parse::<toml::Value>().is_ok())
        .unwrap_or(false)
}

Try / catch

On Err, surface the quoted path and open a repair flow (validator output, compare with config.example.toml); do not silently fall back to defaults, because that would mask user settings.

Prevention

When it happens

Trigger: Loading configuration when config.toml is syntactically invalid TOML, or when known keys carry types or shapes that ConfigToml's serde schema rejects.

Common situations: Hand-edited config with a typo; a field changing type between Codewhale versions leaving an old file incompatible; YAML pasted into the TOML file; truncated file after a crash.

Understand the failure class

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/b11fbd93e692ba16. Report an issue: GitHub.