Hmbown/CodeWhale · error
parsing agent profile
Error message
parsing agent profile {}: {err} What it means
Thrown by load_agent_profile_file when an agent profile .toml file cannot be deserialized into AgentProfileToml. Like the identity variant, it embeds the file path and the underlying toml::de::Error. Note this fires at the toml parse stage; semantic checks that occur afterward (permission expansion, reasoning_effort validation) raise their own distinct errors.
Solutions
- Fix the TOML syntax or field named in the embedded toml::de::Error at the reported path.
- Compare the file against a known-good example profile in the repository's test fixtures or docs.
- Update the profile to the current schema after a version upgrade (renamed/removed fields).
- Re-generate the profile via the tooling instead of hand-editing if schema drift keeps recurring.
Example fix
// before name = "reviewer" tools = "read,grep" // after name = "reviewer" tools = ["read", "grep"]
Defensive patterns
Strategy: validation
Validate before calling
// Rust
let raw = std::fs::read_to_string(path)?;
if let Err(e) = toml::from_str::<AgentProfileToml>(&raw) {
eprintln!("bad profile {}: {e}", path.display());
} Try / catch
// Rust
match load_agent_profiles_from_dir(dir) {
Ok(p) => p,
Err(e) => { log::warn!("skipping profiles: {e:#}"); Vec::new() }
} Prevention
- Copy profiles from current fixtures/docs rather than from memory after upgrades.
- Use an editor with TOML syntax checking enabled.
- After a Codewhale upgrade, diff existing profiles against the changelog for schema renames.
When it happens
Trigger: load_agent_profiles_from_dir or load_agent_profiles_from_dir_tolerant encounters a profile .toml whose contents violate the AgentProfileToml schema: malformed TOML, wrong-typed fields (e.g. tools as string instead of array), or unknown/disallowed keys.
Common situations: Typos in profile keys after editing by hand; schema changed between versions so an old profile uses removed/renamed fields; comments or trailing commas outside TOML grammar; profile copied from docs with placeholder values.
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
- parsing agent profile identity
- Failed to parse configuration; file contents were omitted
- Could not parse configuration for route preference…
- Could not parse destination route identity; contents omitted
- failed to edit permissions at
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/f3b02212c0f4fc04.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/fleet/profile.rs:398
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)
.map_err(|err| anyhow!("parsing agent profile {}: {err}", path.display()))?;
agent_profile_from_toml(path, parsed)
}
fn agent_profile_from_toml(path: &Path, parsed: AgentProfileToml) -> Result<AgentProfile> {
reject_permission_expansion(path, parsed.tools.as_ref(), parsed.permissions.as_ref())?;
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)?;
let role_name = canonical_public_role_name(
first_present([
parsed.base_role.as_deref(),View on GitHub (pinned to 73e0f67d83)