{"record":{"id":"89c39ca6422e164a","repo":"gitbutlerapp/gitbutler","slug":"could-not-determine-anthropic-credential-source","errorCode":null,"errorMessage":"Could not determine Anthropic credential source","messagePattern":"Could not determine Anthropic credential source","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/config.rs","lineNumber":1585,"sourceCode":"                        .prompt_secret(\"Enter OpenAI API key:\")?\n                        .context(\"No API key provided. Aborting configuration.\")?,\n                )\n            } else {\n                None\n            };\n\n            apply_openai_config(repo, scope, key_option, model, endpoint, secret)?;\n        }\n        LLMProviderKind::Anthropic => {\n            let key_options = nonempty::nonempty![\n                (\"Use GitButler API\", AiKeyOption::ButlerApi),\n                (\"Bring your own key\", AiKeyOption::BringYourOwn)\n            ];\n            let key_option = inout\n                .prompt_select(\"Select Anthropic credential source\", &key_options)?\n                .copied()\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\"Could not determine Anthropic credential source\")\n                })?;\n\n            let model = inout.prompt(\"Preferred Anthropic model (leave empty for default):\")?;\n            let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {\n                Some(\n                    inout\n                        .prompt_secret(\"Enter Anthropic API key:\")?\n                        .context(\"No API key provided. Aborting configuration.\")?,\n                )\n            } else {\n                None\n            };\n\n            apply_anthropic_config(repo, scope, key_option, model, secret)?;\n        }\n        LLMProviderKind::Ollama => {\n            let endpoint = inout.prompt(\"Ollama endpoint host:port (optional):\")?;\n            let model = inout.prompt(\"Preferred Ollama model (optional):\")?;","sourceCodeStart":1567,"sourceCodeEnd":1603,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/config.rs#L1567-L1603","documentation":"Analogous to the OpenAI path: when configuring Anthropic in `but config ai`, the 'Select Anthropic credential source' prompt returning `None` raises this anyhow error, since model and key prompts depend on the selected `AiKeyOption`.","triggerScenarios":"User cancels/aborts the Anthropic credential-source selection; prompt runs with non-interactive stdin so prompt_select yields None; broken terminal select UI.","commonSituations":"Mid-setup cancellation in `but config ai`; CI/scripted invocations without TTY; remote shells without pty allocation breaking the picker.","solutions":["Re-run `but config ai` in an interactive terminal and complete the Anthropic selection","Configure the Anthropic key non-interactively (env var such as ANTHROPIC_API_KEY or the git-config keys the provider reads) to bypass the prompt","Fix terminal/pty environment so the select prompt can capture input","Pick a credential source and continue instead of cancelling; cancellation maps to this error"],"exampleFix":"// before: cancelling at the Anthropic prompt\nbut config ai  # Error: Could not determine Anthropic credential source\n\n// after: non-interactive alternative via environment\nexport ANTHROPIC_API_KEY=sk-ant-...\nbut config ai","handlingStrategy":"try-catch","validationCode":"if [ -z \"$ANTHROPIC_API_KEY\" ] && [ ! -t 0 ]; then echo \"set ANTHROPIC_API_KEY or run interactively\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Anthropic credential source\") => {\n        eprintln!(\"Anthropic credential prompt aborted; set key via env instead.\");\n    }\n    r => r?,\n}","preventionTips":["Configure the Anthropic key via env or settings before running config","Complete the wizard in one interactive session","Fix TERM/pty issues if select UIs routinely fail"],"tags":["cli","interactive-prompt","anthropic","credentials"],"backgroundTag":"missing-required-option","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"}