Kuberwastaken/claurst · error

No accounts stored for

Error message

No accounts stored for {provider}

What it means

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.

Solutions

  1. Run the provider's login/add-account flow first so at least one account is stored.
  2. Check the provider name matches the stored key exactly (case-sensitive).
  3. Inspect the accounts store to list which providers actually have accounts before switching.
  4. Handle the Err in callers to prompt the user to add an account instead of switching blindly.

Example fix

// before: switching without any stored accounts
accounts.switch_to("openai", "work")?;

// after: guard on existing accounts
if accounts.provider_accounts("openai").is_empty() {
    add_account("openai")?; // login flow first
}
accounts.switch_to("openai", "work")?;
Defensive patterns

Strategy: type-guard

Validate before calling

if accounts.provider_accounts(provider).is_empty() {
    // run the login/add-account flow before switching
}

Type guard

fn has_accounts(accounts: &Accounts, provider: &str) -> bool {
    accounts.providers.get(provider).map(|s| !s.profiles.is_empty()).unwrap_or(false)
}

Try / catch

match accounts.switch_to(provider, id) {
    Ok(_) => {},
    Err(e) if e.to_string().contains("No accounts stored") => {
        add_account(provider)?;
        accounts.switch_to(provider, id)?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `switch_to(provider, id)` for a provider with zero stored accounts (provider key absent from `self.providers` map).

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Kuberwastaken/claurst@b0637c97ec (2026-09-10). Data as JSON: /api/errors/3bd1c8360b56a122. Report an issue: GitHub.

Appendix: source

Thrown at src-rust/crates/core/src/accounts.rs:187

        }
        let section = self.providers.entry(provider.to_string()).or_default();
        section.profiles.insert(profile.id.clone(), profile.clone());
        if make_active {
            section.active = Some(profile.id.clone());
            if let Some(stored) = section.profiles.get_mut(&profile.id) {
                stored.last_selected_at = Some(now_iso());
            }
        }
        self.save()
    }

    /// Switch the active profile for a provider. Returns `Err` if the id does
    /// not exist.
    pub fn switch_to(&mut self, provider: &str, id: &str) -> anyhow::Result<()> {
        let section = self
            .providers
            .get_mut(provider)
            .ok_or_else(|| anyhow::anyhow!("No accounts stored for {provider}"))?;
        if !section.profiles.contains_key(id) {
            anyhow::bail!("Account '{}' not found for {}", id, provider);
        }
        section.active = Some(id.to_string());
        if let Some(p) = section.profiles.get_mut(id) {
            p.last_selected_at = Some(now_iso());
        }
        self.save()
    }

    /// Remove a profile (and its credential directory). If it was active,
    /// clears the active pointer.
    pub fn remove(&mut self, provider: &str, id: &str) -> anyhow::Result<()> {
        if let Some(section) = self.providers.get_mut(provider) {
            section.profiles.remove(id);
            if section.active.as_deref() == Some(id) {
                section.active = None;
            }

View on GitHub (pinned to b0637c97ec)