{"record":{"id":"d4ee1a0f2db1ef73","repo":"Hmbown/CodeWhale","slug":"duplicate-agent-profile-id","errorCode":null,"errorMessage":"duplicate agent profile id {}","messagePattern":"duplicate agent profile id (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/profile.rs","lineNumber":348,"sourceCode":"\npub fn load_agent_profile_identities_from_dir(\n    dir: impl AsRef<Path>,\n) -> Result<Vec<AgentProfileIdentity>> {\n    let dir = dir.as_ref();\n    agent_profile_paths(dir)?\n        .into_iter()\n        .map(|path| load_agent_profile_identity_file(&path))\n        .collect()\n}\n\npub fn load_agent_profiles_from_dir(dir: impl AsRef<Path>) -> Result<Vec<AgentProfile>> {\n    let dir = dir.as_ref();\n    let mut profiles = Vec::new();\n    let mut seen = BTreeSet::new();\n    for path in agent_profile_paths(dir)? {\n        let profile = load_agent_profile_file(&path)?;\n        if !seen.insert(profile.id.to_ascii_lowercase()) {\n            bail!(\"duplicate agent profile id {}\", profile.id);\n        }\n        profiles.push(profile);\n    }\n    Ok(profiles)\n}\n\nfn agent_profile_paths(dir: &Path) -> Result<Vec<PathBuf>> {\n    if !dir.exists() {\n        return Ok(Vec::new());\n    }\n    if !dir.is_dir() {\n        bail!(\"agent profile path {} is not a directory\", dir.display());\n    }\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()))?","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/profile.rs#L330-L366","documentation":"When loading agent profiles from a directory, the loader collects profile ids into a case-insensitive BTreeSet; if two profile files produce the same id (ignoring case) the loader bails instead of letting a later file silently shadow an earlier one. Agent profile ids must be unique per directory.","triggerScenarios":"Calling load_agent_profiles_from_dir (directly or via load_workspace_agent_profiles) on a directory containing two files that define profiles with ids differing only by case (e.g. `Research.toml` and `research.toml`) or identical ids across files.","commonSituations":"Duplicating a profile file and renaming only the filename, not the `id` field inside; copying profiles between machines so the same id exists in two files; a fresh profile created with a filename that collides case-insensitively with an existing one on a case-insensitive filesystem.","solutions":["Open each profile file in the agent profiles directory and make the `id` values unique","Check for case-only differences (Research vs research) — ids are compared case-insensitively","Remove stale duplicate profile files left over from copies or sync tools","If the duplicate is intentional per-environment, split profiles across different directories"],"exampleFix":"// before: research.toml has id = \"Research\", copied file research-2.toml has id = \"research\"\n// after\n// research.toml:  id = \"research\"\n// research-2.toml: id = \"research-2\"","handlingStrategy":"validation","validationCode":"let mut seen = std::collections::BTreeSet::new();\nfor path in agent_profile_paths(dir)? {\n    let profile = load_agent_profile_file(&path)?;\n    if !seen.insert(profile.id.to_ascii_lowercase()) {\n        eprintln!(\"duplicate profile id: {}\", profile.id);\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"duplicate agent profile id\") => {\n        let id = /* extract id from message */;\n        eprintln!(\"fix or remove a duplicate profile with id {id}\");\n    }\n    other => other?,\n}","preventionTips":["When copying a profile file, always change the id inside, not just the filename","Audit profile directories for case-only filename collisions after syncing from another machine","Script generation of profiles with unique ids"],"tags":["fleet","agent-profiles","duplicate-id","config"],"backgroundTag":"conflicting-config-options","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"}