{"record":{"id":"3bd1c8360b56a122","repo":"Kuberwastaken/claurst","slug":"no-accounts-stored-for-provider","errorCode":null,"errorMessage":"No accounts stored for {provider}","messagePattern":"No accounts stored for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/core/src/accounts.rs","lineNumber":187,"sourceCode":"        }\n        let section = self.providers.entry(provider.to_string()).or_default();\n        section.profiles.insert(profile.id.clone(), profile.clone());\n        if make_active {\n            section.active = Some(profile.id.clone());\n            if let Some(stored) = section.profiles.get_mut(&profile.id) {\n                stored.last_selected_at = Some(now_iso());\n            }\n        }\n        self.save()\n    }\n\n    /// Switch the active profile for a provider. Returns `Err` if the id does\n    /// not exist.\n    pub fn switch_to(&mut self, provider: &str, id: &str) -> anyhow::Result<()> {\n        let section = self\n            .providers\n            .get_mut(provider)\n            .ok_or_else(|| anyhow::anyhow!(\"No accounts stored for {provider}\"))?;\n        if !section.profiles.contains_key(id) {\n            anyhow::bail!(\"Account '{}' not found for {}\", id, provider);\n        }\n        section.active = Some(id.to_string());\n        if let Some(p) = section.profiles.get_mut(id) {\n            p.last_selected_at = Some(now_iso());\n        }\n        self.save()\n    }\n\n    /// Remove a profile (and its credential directory). If it was active,\n    /// clears the active pointer.\n    pub fn remove(&mut self, provider: &str, id: &str) -> anyhow::Result<()> {\n        if let Some(section) = self.providers.get_mut(provider) {\n            section.profiles.remove(id);\n            if section.active.as_deref() == Some(id) {\n                section.active = None;\n            }","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/core/src/accounts.rs#L169-L205","documentation":"Thrown by `Accounts::switch_to` when the provider key has no entry in the accounts store at all. The method looks up `self.providers.get_mut(provider)` and returns this error when the provider section is absent — i.e. no accounts were ever stored for that provider — before it even checks whether the specific account id exists.","triggerScenarios":"Calling `switch_to(provider, id)` for a provider with zero stored accounts (provider key absent from `self.providers` map).","commonSituations":"User adds an account for one provider then tries to switch on another (e.g. stored `anthropic` but calling switch on `openai`); fresh install with no stored accounts; provider name spelled differently than the stored key (\"google\" vs \"gemini\"); store file was reset/deleted.","solutions":["Run the provider's login/add-account flow first so at least one account is stored.","Check the provider name matches the stored key exactly (case-sensitive).","Inspect the accounts store to list which providers actually have accounts before switching.","Handle the Err in callers to prompt the user to add an account instead of switching blindly."],"exampleFix":"// before: switching without any stored accounts\naccounts.switch_to(\"openai\", \"work\")?;\n\n// after: guard on existing accounts\nif accounts.provider_accounts(\"openai\").is_empty() {\n    add_account(\"openai\")?; // login flow first\n}\naccounts.switch_to(\"openai\", \"work\")?;","handlingStrategy":"type-guard","validationCode":"if accounts.provider_accounts(provider).is_empty() {\n    // run the login/add-account flow before switching\n}","typeGuard":"fn has_accounts(accounts: &Accounts, provider: &str) -> bool {\n    accounts.providers.get(provider).map(|s| !s.profiles.is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match accounts.switch_to(provider, id) {\n    Ok(_) => {},\n    Err(e) if e.to_string().contains(\"No accounts stored\") => {\n        add_account(provider)?;\n        accounts.switch_to(provider, id)?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Complete the login/add-account flow for a provider before switching profiles.","Match provider names exactly as stored (case-sensitive keys).","List existing accounts per provider before scripting switches."],"tags":["accounts","profiles","provider","state"],"backgroundTag":"record-not-found","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}