{"record":{"id":"675f5225b8de32da","repo":"gitbutlerapp/gitbutler","slug":"could-not-determine-selected-ai-provider","errorCode":null,"errorMessage":"Could not determine selected AI provider","messagePattern":"Could not determine selected AI provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/config.rs","lineNumber":1548,"sourceCode":"    scope: AiScope,\n) -> Result<()> {\n    let t = theme::get();\n\n    let mut inout = out\n        .prepare_for_terminal_input()\n        .context(\"Human input required - run this in a terminal\")?;\n\n    let providers = nonempty::nonempty![\n        (\"OpenAI\", LLMProviderKind::OpenAi),\n        (\"Anthropic\", LLMProviderKind::Anthropic),\n        (\"Ollama\", LLMProviderKind::Ollama),\n        (\"LM Studio\", LLMProviderKind::LMStudio),\n        (\"OpenRouter\", LLMProviderKind::OpenRouter)\n    ];\n    let provider = inout\n        .prompt_select(\"Select an AI provider\", &providers)?\n        .cloned()\n        .ok_or_else(|| anyhow::anyhow!(\"Could not determine selected AI provider\"))?;\n\n    match provider {\n        LLMProviderKind::OpenAi => {\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 OpenAI credential source\", &key_options)?\n                .copied()\n                .ok_or_else(|| anyhow::anyhow!(\"Could not determine OpenAI credential source\"))?;\n\n            let model = inout.prompt(\"Preferred OpenAI model (leave empty for default):\")?;\n            let endpoint = inout.prompt(\"Custom endpoint URL (optional):\")?;\n\n            let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {\n                Some(\n                    inout","sourceCodeStart":1530,"sourceCodeEnd":1566,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/config.rs#L1530-L1566","documentation":"`but config ai` (interactive AI provider setup) asks the user to pick an LLM provider via `prompt_select` and clones the chosen item. If the prompt returns `None` — no selection made — the code raises this anyhow error because provider selection is required to continue configuration.","triggerScenarios":"Running `but config ai` and cancelling/aborting the provider selection prompt, or running where the select prompt cannot deliver a choice (non-TTY stdin, broken terminal input), so `.cloned()` yields None.","commonSituations":"Non-interactive shells or CI running `but config ai`; user pressing Esc/Ctrl-C at the provider list; terminals where arrow-key select UI fails (dumb TERM, limited pty).","solutions":["Run `but config ai` in an interactive terminal and complete the provider selection","Set the provider non-interactively instead (e.g. via git config keys the CLI reads) if automation is required","Fix terminal environment (TERM type, pty allocation) if the select UI cannot receive input","Abort gracefully is not supported here; choose any provider then configure keys to skip later prompts"],"exampleFix":"// before: non-interactive invocation\nbut config ai < /dev/null  # Error: Could not determine selected AI provider\n\n// after: run in a TTY and select a provider from the list\nbut config ai","handlingStrategy":"try-catch","validationCode":"if [ ! -t 0 ]; then echo \"but config ai requires a TTY\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Could not determine selected AI provider\") => {\n        eprintln!(\"AI provider selection was aborted; config unchanged.\");\n    }\n    r => r?,\n}","preventionTips":["Run `but config ai` only in interactive shells","Configure AI provider via git config / env vars for automation","Complete the selection instead of cancelling mid-prompt"],"tags":["cli","interactive-prompt","ai-config"],"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"}