{"record":{"id":"f1cf65e2ca4187f0","repo":"nikivdev/code","slug":"claude-failed","errorCode":null,"errorMessage":"claude failed: {}","messagePattern":"claude failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":12756,"sourceCode":"\n    if truncated {\n        prompt.push_str(\"\\n\\n[Diff truncated]\");\n    }\n\n    let status = status.trim();\n    if !status.is_empty() {\n        prompt.push_str(\"\\n\\nGit status:\\n\");\n        prompt.push_str(status);\n    }\n\n    let output = Command::new(\"claude\")\n        .args([\"-p\", &prompt])\n        .output()\n        .context(\"failed to run claude for commit message\")?;\n\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\"claude failed: {}\", stderr.trim());\n    }\n\n    let message = String::from_utf8_lossy(&output.stdout).trim().to_string();\n\n    if message.is_empty() {\n        bail!(\"claude returned empty commit message\");\n    }\n\n    Ok(trim_quotes(&message))\n}\n\n/// Generate commit message using Rise daemon (local AI proxy).\nfn generate_commit_message_rise(\n    diff: &str,\n    status: &str,\n    truncated: bool,\n    model: &str,\n) -> Result<String> {","sourceCodeStart":12738,"sourceCodeEnd":12774,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L12738-L12774","documentation":"This error is thrown when the external `claude` CLI exits with a non-zero status during AI commit-message generation. The captured stderr is trimmed and embedded in the message via `bail!`. Note the placeholder is `{}` (not `{:?}`), so if the reported message literally reads \"claude failed: {}\" the stderr was empty and the real failure reason was lost.","triggerScenarios":"Any invocation of `claude -p <prompt>` in the claude commit-message generator that returns a non-zero exit code: claude not authenticated, invalid CLI flags, network failure reaching Anthropic, rate limiting, or the process crashing.","commonSituations":"User logged out of Claude (`claude logout` or expired session); claude CLI updated and `-p` behavior changed; claude not installed or not on PATH; prompt rejected by content filtering; network/proxy failure.","solutions":["Run `claude -p \"test\"` manually to see the raw stderr and fix the underlying CLI issue (usually `claude login`).","Verify the claude CLI is installed and on PATH (`which claude`).","Re-authenticate with `claude login` and retry the commit flow.","Check for CLI version changes that may have altered the `-p` flag and update the tool."],"exampleFix":"// before\nbail!(\"claude failed: {}\", stderr.trim());\n// after\nbail!(\"claude failed: {}\", if stderr.trim().is_empty() { format!(\"exit status {}\", output.status) } else { stderr.trim().to_string() });","handlingStrategy":"try-catch","validationCode":"// Rust: check claude availability before generating\nif which::which(\"claude\").is_err() {\n    return Err(anyhow!(\"claude CLI not found on PATH\"));\n}","typeGuard":"fn claude_failure_clean(stderr: &str, status: &std::process::ExitStatus) -> String {\n    if status.success() { return String::new(); }\n    let s = stderr.trim();\n    if s.is_empty() { format!(\"exit status {}\", status) } else { s.to_string() }\n}","tryCatchPattern":"match generate_claude_commit_message(&diff) {\n    Ok(msg) => msg,\n    Err(e) if e.to_string().starts_with(\"claude failed\") => {\n        eprintln!(\"Run `claude login` and retry: {e}\");\n        fallback_to_manual_message()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep claude CLI authenticated; check auth status before scripted use.","Pin/verify the CLI version so `-p` flag behavior stays stable.","Always capture stderr to surface the real failure reason.","Fall back to a manual or alternate commit-message provider on failure."],"tags":["cli","external-process","authentication","ai"],"backgroundTag":"external-cli-command-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}