Hmbown/CodeWhale · error · anyhow::Error

Unrecognized --provider {provider_arg:?}. Known providers: {

Error message

Unrecognized --provider {provider_arg:?}. Known providers: {} or a configured [providers.<name>] custom provider

What it means

`--provider` must resolve to either a built-in ApiProvider id (parsed case-insensitively, e.g. deepseek, deepseek-cn, zai, moonshot, openrouter, xai, together, ...) or the name of a custom provider declared in a `[providers.<name>]` table in the loaded config (checked via custom_provider_config). If both lookups miss, the CLI bails and prints the built-in names this build knows.

Source

Thrown at crates/tui/src/lib.rs:861

fn apply_exec_provider_override(config: &mut Config, provider_arg: &str) -> Result<()> {
    let provider_arg = provider_arg.trim();
    if provider_arg.is_empty() {
        return Ok(());
    }
    if config
        .providers
        .as_ref()
        .and_then(|providers| providers.custom_provider_config(provider_arg))
        .is_some()
    {
        config.provider = Some(provider_arg.to_string());
        return Ok(());
    }
    if let Some(provider) = crate::config::ApiProvider::parse(provider_arg) {
        config.provider = Some(provider.as_str().to_string());
        return Ok(());
    }
    bail!(
        "Unrecognized --provider {provider_arg:?}. Known providers: {} \
         or a configured [providers.<name>] custom provider",
        crate::config::ApiProvider::names_hint()
    );
}

fn exec_model_env_override() -> Option<String> {
    let read = || {
        ["CODEWHALE_MODEL", "DEEPSEEK_MODEL"]
            .into_iter()
            .find_map(|key| {
                std::env::var(key)
                    .ok()
                    .map(|model| model.trim().to_string())
                    .filter(|model| !model.is_empty())
            })
    };
    #[cfg(test)]

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Re-run and read the printed known-provider list; use the exact id with correct dashes/underscores
  2. For a custom endpoint, add a `[providers.<name>]` table (kind + base_url) to the config and pass that name
  3. Verify which config file is in effect (--config flag, profile) and that the table is inside it
  4. Check case-insensitive spelling: deepseek-cn, deepseek_china, deepseekcn, deepseek-china all parse

Example fix

# before
codewhale exec --provider open_ai "hi"          # Unrecognized --provider "open_ai"

# after (built-in)
codewhale exec --provider openai "hi"

# after (custom, in codewhale config)
[providers.lm-studio]
kind = "openai-compatible"
base_url = "http://127.0.0.1:1234/v1"
# then: codewhale exec --provider lm-studio "hi"
Defensive patterns

Strategy: validation

Validate before calling

# Fail fast on unknown provider ids before launching
PROVIDER="$1"
codewhale exec --provider "$PROVIDER" --help >/dev/null 2>&1 || true
# authoritative check: known built-ins or a [providers.<name>] table in config
grep -q "^\[providers\.$PROVIDER\]" "$(codewhale config path 2>/dev/null || echo config.toml)" \
  || codewhale --help | grep -q "\b$PROVIDER\b" \
  || { echo "unknown provider: $PROVIDER"; exit 2; }

Try / catch

capture stderr; if it matches /Unrecognized --provider/, print the known list from the message and fail fast instead of retrying with the same id

Prevention

When it happens

Trigger: Passing a typo'd or unsupported id (`--provider gpt4`, `--provider open_ai`, `--provider Open AI`); naming a custom provider whose `[providers.<name>]` table is absent from the config file actually loaded (for example when --config points elsewhere); using an id renamed or removed in a newer release.

Common situations: Scripting `codewhale exec --provider` from memory instead of the hint list; adding a local LM Studio/Ollama-compatible endpoint but forgetting the [providers.<name>] table; config drift between machines; legacy aliases like deepseek-china that only ApiProvider::parse accepts.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/836bd139d49714f9. Report an issue: GitHub.