Hmbown/CodeWhale · error · anyhow::Error

unknown field '{field_key}' for built-in provider '{provider

Error message

unknown field '{field_key}' for built-in provider '{provider_id}': expected one of api_key, base_url, model, context_window, mode, auth_mode, insecure_skip_tls_verify, http_headers, path_suffix

What it means

set_custom_provider_value (crates/config/src/lib.rs:2671) rejects `config set providers.<id>.<field>` when <id> is a built-in provider config id. Built-in providers accept a fixed field set (api_key, base_url, model, context_window, mode, auth_mode, insecure_skip_tls_verify, http_headers, path_suffix); without this guard the write fell through to a literal extras key and silently never took effect (#5167). Note `wire` and `kind` are custom-provider-only fields.

Source

Thrown at crates/config/src/lib.rs:2671

            .entry(provider_id.to_string())
            .or_insert_with(|| toml::Value::Table(toml::value::Table::new()));
        entry.as_table_mut().with_context(|| {
            format!("custom provider '{provider_id}' must be a [providers.{provider_id}] table")
        })
    }

    /// Write one leg of a custom provider table. Named custom providers are
    /// not in [`ProviderKind::ALL`], so without this path
    /// `config set providers.<custom>.<field>` fell through to a literal
    /// top-level extras key and silently never took effect (#5167).
    fn set_custom_provider_value(
        &mut self,
        provider_id: &str,
        field_key: &str,
        value: &str,
    ) -> Result<()> {
        if is_builtin_provider_config_id(provider_id) {
            bail!(
                "unknown field '{field_key}' for built-in provider '{provider_id}': \
                 expected one of api_key, base_url, model, context_window, mode, auth_mode, \
                 insecure_skip_tls_verify, http_headers, path_suffix"
            );
        }
        if field_key == "kind" {
            let compatible =
                value.trim().to_ascii_lowercase().replace('_', "-") == "openai-compatible";
            if !compatible {
                bail!(
                    "custom provider '{provider_id}' must set [providers.{provider_id}].kind = \"openai-compatible\""
                );
            }
            self.custom_provider_table_mut(provider_id)?.insert(
                "kind".to_string(),
                toml::Value::String(value.trim().to_string()),
            );
            return Ok(());

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Fix the field name to one from the listed set (e.g. context_window, base_url, api_key)
  2. If you need kind or wire, create a named custom provider id instead of using a built-in one
  3. Check current keys with `config get`-style surfaces before writing

Example fix

# before
codewhale config set providers.openai.contex_window 128000
# -> unknown field 'contex_window' for built-in provider 'openai'

# after
codewhale config set providers.openai.context_window 128000
Defensive patterns

Strategy: validation

Validate before calling

const BUILTIN_FIELDS: &[&str] = &["api_key","base_url","model","context_window","mode","auth_mode","insecure_skip_tls_verify","http_headers","path_suffix"];
assert!(BUILTIN_FIELDS.contains(&field_key)); // before config set on a built-in id

Type guard

fn is_builtin_provider_field(id: &str, field: &str) -> bool {
    is_builtin_provider_config_id(id) && ["api_key","base_url","model","context_window","mode","auth_mode","insecure_skip_tls_verify","http_headers","path_suffix"].contains(&field)
}

Prevention

When it happens

Trigger: Running `codewhale config set providers.openai.<field> <value>` (or any built-in id) where <field> is not in the accepted list — typically a typo like contex_window, or a custom-only field like kind/wire applied to a built-in id.

Common situations: Typos in long CLI field names, assuming the custom-provider field list applies to built-ins, scripting config edits without checking the field name first.

Related errors


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