Hmbown/CodeWhale · error

credential handoff was empty

Error message

credential handoff was empty

What it means

handoff_secret_line refuses to write a credential to stdout when the resolver returned a value that is empty or whitespace-only. The handoff contract is that exactly one non-empty secret line is piped to the consumer, so an empty resolution fails closed before anything is written. Note the resolver's own error is already redacted to 'unavailable credential', so this check is the last guard against a blank secret.

Solutions

  1. Re-set the credential with its actual value in whichever source supplies it (secret store entry, env var, or config field).
  2. Inspect the secret store entry for the provider — delete and recreate it if it is empty.
  3. If your tooling may write blank values, trim/validate on write so empty credentials never persist.
Defensive patterns

Strategy: validation

Validate before calling

if secret.trim().is_empty() {
    return Err("credential for provider X is empty; re-run setup");
}

Type guard

fn is_non_blank(s: &Option<String>) -> bool {
    s.as_deref().map(|v| !v.trim().is_empty()).unwrap_or(false)
}

Prevention

When it happens

Trigger: The resolve closure passed to handoff_secret_line returns Ok with an empty or all-whitespace string — e.g. a secret-store entry exists but stores an empty value, or a config file has a blank api_key field that passed earlier presence checks.

Common situations: A credential was created in the shared secret store with an empty value; a config migration or editor stripped the key's content; an env var is set to "" which some sources treat as present-but-empty.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/cli/src/credential_handoff.rs:66

                .as_deref()
                .is_some_and(auth_mode_uses_kimi_imported_token);
        ensure!(!kimi_bearer, "bearer credentials are not an API key");
    }
    ensure!(source.is_some(), "no runtime-effective API key");
    resolved
        .api_key
        .filter(|value| !value.trim().is_empty())
        .context("no usable runtime-effective API key")
}

pub(crate) fn handoff_secret_line(
    writer: &mut impl Write,
    stdout_is_terminal: bool,
    resolve: impl FnOnce() -> Result<String>,
) -> Result<()> {
    prepare_stdout(stdout_is_terminal)?;
    let secret = Zeroizing::new(resolve().map_err(|_| anyhow::anyhow!("unavailable credential"))?);
    ensure!(!secret.trim().is_empty(), "credential handoff was empty");
    let written = writeln!(writer, "{}", secret.as_str());
    if written.is_ok() || written.is_err_and(|error| error.kind() == ErrorKind::BrokenPipe) {
        return Ok(());
    }
    bail!("credential handoff could not write to stdout")
}
#[cfg(test)]
mod tests;

View on GitHub (pinned to 73e0f67d83)