Hmbown/CodeWhale · error

failed to delete stored credentials for

Error message

failed to delete stored credentials for: {}

What it means

During full logout, Codewhale clears every provider API-key slot from the OS secret store, symmetric with CLI logout. If any slot fails to delete, the logout aborts and the error lists the providers whose stored credentials could not be removed — because leaving credentials behind is a security concern, it fails loud.

Solutions

  1. Retry logout after ensuring the OS secret service is running and unlocked (e.g. start gnome-keyring, unlock the Keychain)
  2. Delete the listed entries manually via your secret-service tool, then retry
  3. Run logout in an environment where the same user session owns the keychain that stored the keys
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the secret service is reachable before logout
credential_secret_store().ok_or("OS secret store unavailable; unlock keychain first")?;

Try / catch

match logout_result {
    Err(e) if e.to_string().starts_with("failed to delete stored credentials") => {
        eprintln!("unlock/restart the secret service, then retry logout: {e}");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling the logout/clear-all routine when `clear_all_provider_api_keys_from_secret_store` returns failures (secret service unavailable, keychain denied access, individual entry deletion errors).

Common situations: macOS Keychain denying access from an unsigned/rebuilt binary; Linux with no secret-service daemon (gnome-keyring not running); stale keyring entries locked behind a session.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/19906624c9a344c2. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/config.rs:13312

            "credential.clear",
            json!({
                "backend": "config_file",
                "config_path": config_path.display().to_string(),
                "scope": "root_and_provider_keys",
            }),
        );
    }

    // The config scrub alone leaves the durable secret-store credential
    // alive, and the read chain prefers the secret store over the file, so a
    // "cleared" key silently came back on the next launch (#5196). Delete
    // every provider slot too, symmetric with CLI logout (#5159). This runs
    // even when the config file is absent: the slot survives independently
    // of the file.
    if let Some(secrets) = credential_secret_store() {
        let failures = clear_all_provider_api_keys_from_secret_store(secrets);
        if !failures.is_empty() {
            anyhow::bail!(
                "failed to delete stored credentials for: {}",
                failures.join(", ")
            );
        }
    }

    Ok(())
}

/// Delete the credential slot of every provider that has one stored.
///
/// Mirrors the CLI logout helper (#5159): each slot is probed first so
/// backends that error on deleting a missing item stay quiet, slots shared
/// by several providers (e.g. the historical `siliconflow` slot) are deleted
/// once, and every deletion failure is returned as a human-readable entry so
/// the caller can fail loudly instead of claiming a clean logout while
/// credentials linger in the store (#5196).
fn clear_all_provider_api_keys_from_secret_store(

View on GitHub (pinned to 73e0f67d83)