{"record":{"id":"76608f8e607c55cb","repo":"Hmbown/CodeWhale","slug":"credential-handoff-was-empty","errorCode":null,"errorMessage":"credential handoff was empty","messagePattern":"credential handoff was empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/credential_handoff.rs","lineNumber":66,"sourceCode":"                .as_deref()\n                .is_some_and(auth_mode_uses_kimi_imported_token);\n        ensure!(!kimi_bearer, \"bearer credentials are not an API key\");\n    }\n    ensure!(source.is_some(), \"no runtime-effective API key\");\n    resolved\n        .api_key\n        .filter(|value| !value.trim().is_empty())\n        .context(\"no usable runtime-effective API key\")\n}\n\npub(crate) fn handoff_secret_line(\n    writer: &mut impl Write,\n    stdout_is_terminal: bool,\n    resolve: impl FnOnce() -> Result<String>,\n) -> Result<()> {\n    prepare_stdout(stdout_is_terminal)?;\n    let secret = Zeroizing::new(resolve().map_err(|_| anyhow::anyhow!(\"unavailable credential\"))?);\n    ensure!(!secret.trim().is_empty(), \"credential handoff was empty\");\n    let written = writeln!(writer, \"{}\", secret.as_str());\n    if written.is_ok() || written.is_err_and(|error| error.kind() == ErrorKind::BrokenPipe) {\n        return Ok(());\n    }\n    bail!(\"credential handoff could not write to stdout\")\n}\n#[cfg(test)]\nmod tests;\n","sourceCodeStart":48,"sourceCodeEnd":75,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/cli/src/credential_handoff.rs#L48-L75","documentation":"Raised in handoff_secret_line when the credential handoff payload resolved to an empty string. The handoff contract is to write exactly the secret plus one newline to the consumer (pipe or terminal); an empty secret would settle the pipe with no credential, so it is treated as a resolution failure and redacted rather than emitted.","triggerScenarios":"Thrown at crates/cli/src/credential_handoff.rs:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-enter or re-import the API key so the store holds a real value.","Check upstream credential import steps for silent failures that left an empty key."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}