{"record":{"id":"0f3c93774a64fedf","repo":"nikivdev/code","slug":"ai-task-sh-failed","errorCode":null,"errorMessage":"ai-task.sh failed: {}","messagePattern":"ai-task\\.sh failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/explain_commits.rs","lineNumber":246,"sourceCode":"            \"--prompt\",\n            &prompt,\n            \"--max-steps\",\n            \"5\",\n        ])\n        .output();\n\n    match output {\n        Ok(out) if out.status.success() => {\n            let text = String::from_utf8_lossy(&out.stdout).trim().to_string();\n            if text.is_empty() {\n                Ok(\"(AI returned empty response)\".to_string())\n            } else {\n                Ok(text)\n            }\n        }\n        Ok(out) => {\n            let stderr = String::from_utf8_lossy(&out.stderr);\n            bail!(\"ai-task.sh failed: {}\", stderr.trim());\n        }\n        Err(e) => {\n            bail!(\"failed to run ai-task.sh: {e}\");\n        }\n    }\n}\n\n// -- Markdown output --\n\nfn slugify(s: &str) -> String {\n    s.chars()\n        .map(|c| {\n            if c.is_alphanumeric() || c == '-' {\n                c.to_ascii_lowercase()\n            } else if c == ' ' || c == '_' || c == '/' {\n                '-'\n            } else {\n                '\\0'","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/explain_commits.rs#L228-L264","documentation":"`call_ai_explain` delegates explanation to an external `ai-task.sh` script. When the script runs but exits non-zero, this error surfaces the script's trimmed stderr. It is an integration failure of the external AI helper, not a git or parsing problem.","triggerScenarios":"The spawned ai-task.sh process completes with a non-zero exit status (the `Ok(out)` arm at src/explain_commits.rs:246); stderr from the script is included in the message.","commonSituations":"AI provider API key missing/expired inside the script; ai-task.sh updated to a version requiring new env vars or config; network outage inside the script; script's own error paths (prompt too large, quota exhausted).","solutions":["Run ai-task.sh manually with the same input to see its full stderr","Check the AI provider credentials/keys the script relies on (env vars like API keys)","Verify script config/quota — rate limits or exhausted credits commonly cause non-zero exits","Update or repair ai-task.sh if it references a changed provider API","As a workaround, write the commit explanation manually without the AI path"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// check the AI script and its credentials before invoking\nlet cfg = std::path::Path::new(\"scripts/ai-task.sh\");\nif !cfg.exists() { bail!(\"ai-task.sh missing — AI explanation unavailable\"); }\nif std::env::var(\"AI_API_KEY\").is_err() { bail!(\"AI_API_KEY not set — ai-task.sh will fail\"); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"ai-task.sh failed\") => {\n        eprintln!(\"AI explanation unavailable ({e}); falling back to raw commit list\");\n        print_raw_commit_list()?;\n    }\n    other => other?,\n}","preventionTips":["Keep AI provider API keys and quotas valid for the script","Pin/monitor the ai-task.sh version your workflow expects","Run the script manually once after setup to validate the integration","Provide a non-AI fallback path for CI"],"tags":["subprocess","ai","integration","script"],"backgroundTag":"external-script-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}