{"record":{"id":"39604eccdf03c69d","repo":"zeroclaw-labs/zeroclaw","slug":"auth-profile-not-found-profile-id","errorCode":null,"errorMessage":"Auth profile not found: {profile_id}","messagePattern":"Auth profile not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/auth/profiles.rs","lineNumber":218,"sourceCode":"\n        let removed = data.profiles.remove(profile_id).is_some();\n        if !removed {\n            return Ok(false);\n        }\n\n        data.active_profiles\n            .retain(|_, active| active != profile_id);\n        data.updated_at = Utc::now();\n        self.save_locked(&data).await?;\n        Ok(true)\n    }\n\n    pub async fn set_active_profile(&self, model_provider: &str, profile_id: &str) -> Result<()> {\n        let _lock = self.acquire_lock().await?;\n        let mut data = self.load_locked().await?;\n\n        if !data.profiles.contains_key(profile_id) {\n            anyhow::bail!(\"Auth profile not found: {profile_id}\");\n        }\n\n        data.active_profiles\n            .insert(model_provider.to_string(), profile_id.to_string());\n        data.updated_at = Utc::now();\n        self.save_locked(&data).await\n    }\n\n    pub async fn clear_active_profile(&self, model_provider: &str) -> Result<()> {\n        let _lock = self.acquire_lock().await?;\n        let mut data = self.load_locked().await?;\n        data.active_profiles.remove(model_provider);\n        data.updated_at = Utc::now();\n        self.save_locked(&data).await\n    }\n\n    pub async fn update_profile<F>(&self, profile_id: &str, mut updater: F) -> Result<AuthProfile>\n    where","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/auth/profiles.rs#L200-L236","documentation":"`AuthProfilesStore::set_active_profile` refuses to point a model provider at a profile ID that does not exist in the store. Profile IDs are structured strings `{model_provider}:{profile_name}` produced by `profile_id()` (e.g. `openai-codex:default`); the existence check runs after the file lock is acquired, before any mutation, so nothing is written on failure.","triggerScenarios":"Calling `set_active_profile(\"openai-codex\", \"default\")` when the store contains no profile with id `openai-codex:default`; passing a bare profile name instead of the full id; whitespace or case differences from the trimmed format `profile_id()` produces.","commonSituations":"The profile was removed in another session; a script hardcodes an ID that was never created; wrong provider prefix (`openai` vs `openai-codex`) after a rename.","solutions":["Call `list_profile_ids()` and use an existing ID verbatim","Build the ID with `profile_id(model_provider, profile_name)` so formatting matches exactly","If the profile should exist, `upsert_profile` it first, then set it active","Check for typos in the provider segment — it must equal the stored profile's model_provider"],"exampleFix":"// before: assumes the profile exists\nstore.set_active_profile(\"openai-codex\", \"default\").await?; // \"Auth profile not found: openai-codex:default\"\n\n// after: verify (or create) before activating\nlet id = profile_id(\"openai-codex\", \"default\");\nif !store.list_profile_ids().await?.contains(&id) {\n    store.upsert_profile(AuthProfile::new_oauth(/* ... */), false).await?;\n}\nstore.set_active_profile(\"openai-codex\", &id).await?;","handlingStrategy":"validation","validationCode":"let ids = store.list_profile_ids().await?;\nlet id = profile_id(\"openai-codex\", \"default\");\nif ids.contains(&id) {\n    store.set_active_profile(\"openai-codex\", &id).await?;\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = store.set_active_profile(provider, &id).await {\n    if e.to_string().contains(\"Auth profile not found\") {\n        let available = store.list_profile_ids().await?; // surface valid ids for recovery\n        return Err(anyhow!(\"unknown profile {id}; available: {available:?}\"));\n    }\n    return Err(e);\n}","preventionTips":["Derive IDs with profile_id() instead of formatting strings by hand","Call list_profile_ids() before set/remove operations","Upsert a profile before activating it"],"tags":["auth","profiles","store","configuration","rust"],"backgroundTag":"auth-profile-not-found","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}