zeroclaw-labs/zeroclaw · error · anyhow::Error

Auth profile not found: {profile_id}

Error message

Auth profile not found: {profile_id}

What it means

`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.

Source

Thrown at crates/zeroclaw-providers/src/auth/profiles.rs:218

        let removed = data.profiles.remove(profile_id).is_some();
        if !removed {
            return Ok(false);
        }

        data.active_profiles
            .retain(|_, active| active != profile_id);
        data.updated_at = Utc::now();
        self.save_locked(&data).await?;
        Ok(true)
    }

    pub async fn set_active_profile(&self, model_provider: &str, profile_id: &str) -> Result<()> {
        let _lock = self.acquire_lock().await?;
        let mut data = self.load_locked().await?;

        if !data.profiles.contains_key(profile_id) {
            anyhow::bail!("Auth profile not found: {profile_id}");
        }

        data.active_profiles
            .insert(model_provider.to_string(), profile_id.to_string());
        data.updated_at = Utc::now();
        self.save_locked(&data).await
    }

    pub async fn clear_active_profile(&self, model_provider: &str) -> Result<()> {
        let _lock = self.acquire_lock().await?;
        let mut data = self.load_locked().await?;
        data.active_profiles.remove(model_provider);
        data.updated_at = Utc::now();
        self.save_locked(&data).await
    }

    pub async fn update_profile<F>(&self, profile_id: &str, mut updater: F) -> Result<AuthProfile>
    where

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Call `list_profile_ids()` and use an existing ID verbatim
  2. Build the ID with `profile_id(model_provider, profile_name)` so formatting matches exactly
  3. If the profile should exist, `upsert_profile` it first, then set it active
  4. Check for typos in the provider segment — it must equal the stored profile's model_provider

Example fix

// before: assumes the profile exists
store.set_active_profile("openai-codex", "default").await?; // "Auth profile not found: openai-codex:default"

// after: verify (or create) before activating
let id = profile_id("openai-codex", "default");
if !store.list_profile_ids().await?.contains(&id) {
    store.upsert_profile(AuthProfile::new_oauth(/* ... */), false).await?;
}
store.set_active_profile("openai-codex", &id).await?;
Defensive patterns

Strategy: validation

Validate before calling

let ids = store.list_profile_ids().await?;
let id = profile_id("openai-codex", "default");
if ids.contains(&id) {
    store.set_active_profile("openai-codex", &id).await?;
}

Try / catch

if let Err(e) = store.set_active_profile(provider, &id).await {
    if e.to_string().contains("Auth profile not found") {
        let available = store.list_profile_ids().await?; // surface valid ids for recovery
        return Err(anyhow!("unknown profile {id}; available: {available:?}"));
    }
    return Err(e);
}

Prevention

When it happens

Trigger: 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.

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

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/39604eccdf03c69d. Report an issue: GitHub.