{"record":{"id":"f3b02212c0f4fc04","repo":"Hmbown/CodeWhale","slug":"parsing-agent-profile-err","errorCode":null,"errorMessage":"parsing agent profile {}: {err}","messagePattern":"parsing agent profile (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/profile.rs","lineNumber":398,"sourceCode":"    let fallback_id = path\n        .file_stem()\n        .and_then(|value| value.to_str())\n        .unwrap_or(\"profile\");\n    let id = first_present([parsed.id.as_deref(), parsed.name.as_deref()])\n        .unwrap_or(fallback_id)\n        .to_string();\n    validate_agent_profile_token(path, \"id/name\", &id)?;\n    Ok(AgentProfileIdentity {\n        id,\n        source: path.to_path_buf(),\n    })\n}\n\nfn load_agent_profile_file(path: &Path) -> Result<AgentProfile> {\n    let raw = std::fs::read_to_string(path)\n        .with_context(|| format!(\"reading agent profile {}\", path.display()))?;\n    let parsed: AgentProfileToml = toml::from_str(&raw)\n        .map_err(|err| anyhow!(\"parsing agent profile {}: {err}\", path.display()))?;\n    agent_profile_from_toml(path, parsed)\n}\n\nfn agent_profile_from_toml(path: &Path, parsed: AgentProfileToml) -> Result<AgentProfile> {\n    reject_permission_expansion(path, parsed.tools.as_ref(), parsed.permissions.as_ref())?;\n\n    let fallback_id = path\n        .file_stem()\n        .and_then(|value| value.to_str())\n        .unwrap_or(\"profile\");\n    let id = first_present([parsed.id.as_deref(), parsed.name.as_deref()])\n        .unwrap_or(fallback_id)\n        .to_string();\n    validate_agent_profile_token(path, \"id/name\", &id)?;\n\n    let role_name = canonical_public_role_name(\n        first_present([\n            parsed.base_role.as_deref(),","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/profile.rs#L380-L416","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nname = \"reviewer\"\ntools = \"read,grep\"\n// after\nname = \"reviewer\"\ntools = [\"read\", \"grep\"]","handlingStrategy":"validation","validationCode":"// Rust\nlet raw = std::fs::read_to_string(path)?;\nif let Err(e) = toml::from_str::<AgentProfileToml>(&raw) {\n    eprintln!(\"bad profile {}: {e}\", path.display());\n}","typeGuard":null,"tryCatchPattern":"// Rust\nmatch load_agent_profiles_from_dir(dir) {\n    Ok(p) => p,\n    Err(e) => { log::warn!(\"skipping profiles: {e:#}\"); Vec::new() }\n}","preventionTips":["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."],"tags":["toml","parse-error","configuration","deserialization"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}