Hmbown/CodeWhale · error

unknown field ' ' for custom provider ' ': expected one of

Error message

unknown field '{field_key}' for custom provider '{provider_id}': expected one of {CUSTOM_PROVIDER_FIELD_HINT}

What it means

For custom providers, any field key that does not parse into ProviderConfigField is rejected with the full list of accepted fields (CUSTOM_PROVIDER_FIELD_HINT). This is a fail-fast guard against typos and unsupported keys in [providers.<custom-id>] tables.

Solutions

  1. Use a field from CUSTOM_PROVIDER_FIELD_HINT (the message itself lists valid names)
  2. Fix spelling/underscores (e.g. http_headers, base_url, context_window)
  3. For unknown extras, check whether a newer version supports the field or use http_headers to pass HTTP-level configuration

Example fix

// before
codewhale config set providers.myapi.headers '{"X-Org":"1"}'
// after
codewhale config set providers.myapi.http_headers '{"X-Org":"1"}'
Defensive patterns

Strategy: validation

Validate before calling

let hint_fields = ["api_key","base_url","model","mode","context_window","http_headers","path_suffix","kind"]; // per CUSTOM_PROVIDER_FIELD_HINT
if !hint_fields.contains(&field_key) {
    return Err(format!("unknown custom provider field {field_key}"));
}

Try / catch

match result {
    Err(e) if e.to_string().contains("unknown field") => eprintln!("{e}"), // message lists valid fields
    other => other?,
}

Prevention

When it happens

Trigger: set_custom_provider_value called with a field_key that is not "kind" and not in the hint list — e.g. misspelled `contextwindow`, `headers` instead of `http_headers`, or a field only valid for built-ins.

Common situations: Typing field names from memory in config.toml; scripting `config set providers.myapi.ky <value>`; assuming custom providers accept the same set as built-ins (e.g. auth_mode or insecure_skip_tls_verify) when the hint list differs.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/fb13acb3cd28b432. Report an issue: GitHub.

Appendix: source

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

                 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(());
        }
        let Some(field) = ProviderConfigField::parse(field_key) else {
            bail!(
                "unknown field '{field_key}' for custom provider '{provider_id}': \
                 expected one of {CUSTOM_PROVIDER_FIELD_HINT}"
            );
        };
        let toml_value = match field {
            ProviderConfigField::Vendor => {
                bail!("vendor is only supported by providers.openrouter")
            }
            ProviderConfigField::ApiKey
            | ProviderConfigField::BaseUrl
            | ProviderConfigField::Model
            | ProviderConfigField::Mode
            | ProviderConfigField::Wire
            | ProviderConfigField::AuthMode
            | ProviderConfigField::PathSuffix => toml::Value::String(value.to_string()),
            ProviderConfigField::ContextWindow => {
                toml::Value::Integer(i64::from(parse_context_window(value)?))
            }

View on GitHub (pinned to 73e0f67d83)