{"record":{"id":"db09aca9f63d2a00","repo":"gitbutlerapp/gitbutler","slug":"no-ai-credentials-found-configure-in-gitbutler-se","errorCode":null,"errorMessage":"No AI credentials found. Configure in GitButler settings or set OPENAI_API_KEY environment variable.","messagePattern":"No AI credentials found\\. Configure in GitButler settings or set OPENAI_API_KEY environment variable\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/branch/show.rs","lineNumber":420,"sourceCode":"    author_email: String,\n    timestamp: i64,\n    files_changed: usize,\n    insertions: usize,\n    deletions: usize,\n    files: Vec<FileChange>,\n}\n\n#[instrument(skip(commits, git_config))]\nfn generate_branch_summary(\n    branch_name: &str,\n    commits: &[CommitInfo],\n    git_config: &gix::config::File,\n) -> anyhow::Result<String> {\n    use but_llm::LLMProvider;\n\n    // Get OpenAI provider (tries GitButler proxied, own key, then env var)\n    let llm = LLMProvider::from_git_config(git_config).ok_or_else(|| {\n        anyhow::anyhow!(\n            \"No AI credentials found. Configure in GitButler settings or set OPENAI_API_KEY environment variable.\"\n        )\n    })?;\n\n    // Build the prompt with commit information\n    let mut prompt = format!(\n        \"Please provide a concise summary (2-3 sentences) of what this branch '{branch_name}' accomplishes based on the following commits:\\n\\n\"\n    );\n\n    for commit in commits {\n        prompt.push_str(&format!(\"- {}: {}\\n\", commit.short_sha, commit.message));\n        if !commit.files.is_empty() {\n            prompt.push_str(\"  Files changed:\\n\");\n            for file in &commit.files {\n                prompt.push_str(&format!(\n                    \"    {} ({}, +{}, -{})\\n\",\n                    file.path, file.status, file.insertions, file.deletions\n                ));","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/branch/show.rs#L402-L438","documentation":"`but branch show --summary` (generate_branch_summary) needs an LLM client. `LLMProvider::from_git_config` tries GitButler proxied credentials, a user's own key in git config, then OPENAI_API_KEY; if all are absent it returns None and the code raises this anyhow error instead of generating the AI summary.","triggerScenarios":"Running a branch-summary feature with no AI credentials anywhere: no GitButler account/proxy auth, no ai key in git config, and OPENAI_API_KEY unset in the environment.","commonSituations":"Fresh machine or CI without credentials configured; users who never signed into GitButler; environments that strip env vars (systemd, docker, CI runners) so OPENAI_API_KEY is missing; rotating/revoked keys removed from config.","solutions":["Set the OPENAI_API_KEY environment variable before running the command","Configure a provider key in GitButler settings (or git config) via `but config ai`","Sign in / authenticate with GitButler so the proxied Butler API can be used","Check the key actually reaches the process (export in the same shell, not just .bashrc when run from CI)"],"exampleFix":"// before\nbut branch show main --summary\n// Error: No AI credentials found...\n\n// after\nexport OPENAI_API_KEY=sk-...\nbut branch show main --summary","handlingStrategy":"fallback","validationCode":"if [ -z \"$OPENAI_API_KEY\" ]; then\n  git config --get gitbutler.aiKey >/dev/null || { echo \"No AI credentials configured\"; exit 1; }\nfi","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"No AI credentials found\") => {\n        eprintln!(\"Skipping AI summary: configure credentials or set OPENAI_API_KEY.\");\n    }\n    r => r?,\n}","preventionTips":["Export OPENAI_API_KEY in shells/CI that run summary commands","Complete `but config ai` once per machine","Check env inheritance when using systemd/docker/CI wrappers"],"tags":["ai","credentials","openai","api-key","environment"],"backgroundTag":"missing-credentials","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}