{"record":{"id":"2c511751da7cca4e","repo":"Hmbown/CodeWhale","slug":"parsing-agent-profile-identity-err","errorCode":null,"errorMessage":"parsing agent profile identity {}: {err}","messagePattern":"parsing agent profile identity (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/profile.rs","lineNumber":379,"sourceCode":"    }\n\n    let mut paths = std::fs::read_dir(dir)\n        .with_context(|| format!(\"reading agent profile dir {}\", dir.display()))?\n        .collect::<std::io::Result<Vec<_>>>()\n        .with_context(|| format!(\"reading agent profile entries in {}\", dir.display()))?\n        .into_iter()\n        .map(|entry| entry.path())\n        .filter(|path| path.extension().and_then(|value| value.to_str()) == Some(\"toml\"))\n        .collect::<Vec<_>>();\n    paths.sort();\n    Ok(paths)\n}\n\nfn load_agent_profile_identity_file(path: &Path) -> Result<AgentProfileIdentity> {\n    let raw = std::fs::read_to_string(path)\n        .with_context(|| format!(\"reading agent profile identity {}\", path.display()))?;\n    let parsed: AgentProfileIdentityToml = toml::from_str(&raw)\n        .map_err(|err| anyhow!(\"parsing agent profile identity {}: {err}\", path.display()))?;\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    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)","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/profile.rs#L361-L397","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Validate the file parses as TOML (e.g. `python3 -c \"import tomllib;tomllib.load(open('<path>','rb'))\"`) before reloading.","Ensure `id` or `name` is a quoted string and remove unknown keys the AgentProfileIdentityToml schema does not define.","Restore the file from version control or a backup if it was corrupted."],"exampleFix":"// before (broken identity toml)\nid = 42\nrole = [consultant]\n// after\nid = \"reviewer-1\"\nrole = \"consultant\"","handlingStrategy":"validation","validationCode":"// Rust\nlet raw = std::fs::read_to_string(path)?;\nlet parsed: Result<AgentProfileIdentityToml, _> = toml::from_str(&raw);\nif let Err(e) = parsed { eprintln!(\"bad identity {}: {e}\", path.display()); }","typeGuard":null,"tryCatchPattern":"// Rust\nmatch load_agent_profile_identities_from_dir(dir) {\n    Ok(ids) => ids,\n    Err(e) if e.to_string().contains(\"parsing agent profile identity\") => Vec::new(), // skip dir\n    Err(e) => return Err(e),\n}","preventionTips":["Run a TOML linter (taplo) over profile directories after hand edits.","Quote all string fields in identity files; never rely on bare/typed values.","Keep identity files under version control to spot accidental schema edits in review."],"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"}