Hmbown/CodeWhale · error

Refusing to save an empty API key.

Error message

Refusing to save an empty API key.

What it means

Error "Refusing to save an empty API key." thrown in Hmbown/CodeWhale.

Source

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

/// removed. When the secret-store write fails (OS permission denied, corrupt
/// or read-only file backend, etc.), the save fails loudly rather than writing
/// the key to plaintext `config.toml`.
///
/// Under `cfg(test)` the secret-store path is enabled only when the test sets
/// both an isolated `CODEWHALE_HOME` and an explicit backend, preventing unit
/// tests from touching the developer's real credential store.
pub fn save_api_key(api_key: &str) -> Result<SavedCredential> {
    save_root_api_key_for_secret_slot(api_key, "deepseek", true)
}

fn save_root_api_key_for_secret_slot(
    api_key: &str,
    secret_slot: &str,
    clear_deepseek_provider_slot: bool,
) -> Result<SavedCredential> {
    let trimmed = api_key.trim();
    if trimmed.is_empty() {
        anyhow::bail!("Refusing to save an empty API key.");
    }

    let path = credential_config_path().context("Failed to resolve config path for API key.")?;

    if let Some(secrets) = credential_secret_store() {
        let prior_secret = secrets.get(secret_slot);
        match prior_secret.as_ref() {
            Ok(prior) => match secrets.set(secret_slot, trimmed) {
                Ok(()) => {
                    if let Err(error) = save_root_api_key_metadata_without_plaintext(
                        &path,
                        clear_deepseek_provider_slot,
                    ) {
                        let current = secrets.get(secret_slot).map_err(|rollback| {
                        anyhow::anyhow!(
                            "{error}; additionally could not verify secret-store rollback for {secret_slot}: {rollback}"
                        )
                    })?;

View on GitHub (pinned to 8880682c63)

When it happens

Trigger: Thrown at crates/tui/src/config.rs:10314 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/b935d1d45353302e. Report an issue: GitHub.