Hmbown/CodeWhale · error

parsing agent profile identity

Error message

parsing agent profile identity {}: {err}

What it means

Thrown by load_agent_profile_identity_file when an agent profile identity TOML file (e.g. an identity/roster entry under the Fleet profiles directory) fails to deserialize into AgentProfileIdentityToml. The error names the file path and embeds the toml::de::Error, so it pinpoints both the offending file and the offending field/syntax. Callers using the *_tolerant variants skip such files; strict loaders propagate it.

Solutions

  1. Read the toml::de::Error detail in the message (it names the line/column or field) and fix that spot in the file at the given path.
  2. Validate the file parses as TOML (e.g. `python3 -c "import tomllib;tomllib.load(open('<path>','rb'))"`) before reloading.
  3. Ensure `id` or `name` is a quoted string and remove unknown keys the AgentProfileIdentityToml schema does not define.
  4. Restore the file from version control or a backup if it was corrupted.

Example fix

// before (broken identity toml)
id = 42
role = [consultant]
// after
id = "reviewer-1"
role = "consultant"
Defensive patterns

Strategy: validation

Validate before calling

// Rust
let raw = std::fs::read_to_string(path)?;
let parsed: Result<AgentProfileIdentityToml, _> = toml::from_str(&raw);
if let Err(e) = parsed { eprintln!("bad identity {}: {e}", path.display()); }

Try / catch

// Rust
match load_agent_profile_identities_from_dir(dir) {
    Ok(ids) => ids,
    Err(e) if e.to_string().contains("parsing agent profile identity") => Vec::new(), // skip dir
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling load_agent_profiles_from_dir_tolerant / load_plugin_agent_profiles_from_component / load_agent_profile_identities_from_dir on a directory containing an identity .toml with invalid TOML syntax, an unexpected field type (e.g. id as integer), or schema fields the struct does not accept.

Common situations: Hand-edited identity file with a missing quote or wrong indentation; id/name written as a number instead of string; file copied from another tool with incompatible keys; truncated file from an interrupted write.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/2c511751da7cca4e. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/profile.rs:379

    }

    let mut paths = std::fs::read_dir(dir)
        .with_context(|| format!("reading agent profile dir {}", dir.display()))?
        .collect::<std::io::Result<Vec<_>>>()
        .with_context(|| format!("reading agent profile entries in {}", dir.display()))?
        .into_iter()
        .map(|entry| entry.path())
        .filter(|path| path.extension().and_then(|value| value.to_str()) == Some("toml"))
        .collect::<Vec<_>>();
    paths.sort();
    Ok(paths)
}

fn load_agent_profile_identity_file(path: &Path) -> Result<AgentProfileIdentity> {
    let raw = std::fs::read_to_string(path)
        .with_context(|| format!("reading agent profile identity {}", path.display()))?;
    let parsed: AgentProfileIdentityToml = toml::from_str(&raw)
        .map_err(|err| anyhow!("parsing agent profile identity {}: {err}", path.display()))?;
    let fallback_id = path
        .file_stem()
        .and_then(|value| value.to_str())
        .unwrap_or("profile");
    let id = first_present([parsed.id.as_deref(), parsed.name.as_deref()])
        .unwrap_or(fallback_id)
        .to_string();
    validate_agent_profile_token(path, "id/name", &id)?;
    Ok(AgentProfileIdentity {
        id,
        source: path.to_path_buf(),
    })
}

fn load_agent_profile_file(path: &Path) -> Result<AgentProfile> {
    let raw = std::fs::read_to_string(path)
        .with_context(|| format!("reading agent profile {}", path.display()))?;
    let parsed: AgentProfileToml = toml::from_str(&raw)

View on GitHub (pinned to 73e0f67d83)