Hmbown/CodeWhale · error
unavailable credential
Error message
unavailable credential
What it means
handoff_secret_line resolves a credential via a caller-supplied closure and writes it to stdout for a pipe consumer. Any error from the resolver is collapsed into the generic message "unavailable credential" so that the secret source and OS error details never leak to output. It signals the credential could not be retrieved at handoff time.
Solutions
- Log in / set the credential for the selected provider before piping (run the interactive auth flow once)
- Verify the provider/profile selected is the one that actually has a key configured
- Check that the OS secret service (keyring/agent) is reachable in the current environment
- Inspect upstream logs for the redacted underlying resolver error
Example fix
// before: piping handoff with no stored credential $ codewhale auth ... --pipe | consumer // after: ensure credential exists first $ codewhale login $ codewhale auth ... --pipe | consumer
Defensive patterns
Strategy: try-catch
Validate before calling
// before piping, confirm a credential is resolvable
if resolve().is_err() {
eprintln!("no stored credential for selected provider; run the login flow first");
} Try / catch
match handoff_secret_line(&mut out, is_tty, resolve) {
Ok(()) => {},
Err(e) if e.to_string() == "unavailable credential" => {
eprintln!("credential unavailable — run `codewhale login` before piping");
}
Err(e) => return Err(e),
} Prevention
- Run the interactive login once before scripting piped handoffs
- In CI, provision credentials explicitly (env/file secret store) rather than relying on a desktop keyring
- Never assume pipe failures include secret details — the message is intentionally redacted; log the resolver outcome separately on success/failure
When it happens
Trigger: The `resolve` closure passed to handoff_secret_line returns Err — e.g. the auth store has no API key for the selected provider, the keyring/backend read fails, or config loading failed before resolution.
Common situations: Running a piped command that hands off an API key when the provider was never logged in, the credential was revoked/deleted, or a headless CI environment lacks the secret store the desktop login populated.
Related errors
- credential handoff was empty
- no runtime-effective API key
- refusing terminal output; pipe credential handoff to the…
- unavailable credential
- a CNB access token is not configured in the Codewhale…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/ab24a4e792843d42.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/credential_handoff.rs:65
.auth_mode
.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)