alibaba/open-code-review · error

unknown provider field %q: supported fields are api_key, api

Error message

unknown provider field %q: supported fields are api_key, api_key_cmd, url, protocol, model, models, auth_header, extra_body, extra_headers, retry_codes, aws_region, aws_profile

What it means

The default branch of applyProviderField rejects any field name outside the supported list: api_key, api_key_cmd, url, protocol, model, models, auth_header, extra_body, extra_headers, retry_codes, aws_region, aws_profile. The error message includes the full supported list to guide correction.

Source

Thrown at cmd/opencodereview/config_cmd.go:688

		for _, w := range warnings {
			fmt.Fprintf(os.Stderr, "[ocr] WARNING: %s\n", w)
		}
		entry.RetryCodes = codes
	case "aws_region", "aws_profile":
		normalized, err := normalizeAWSSetting(field, key, value)
		if err != nil {
			return err
		}
		if !providerAcceptsAWSSettings(providerName, entry) {
			return fmt.Errorf("%s does not apply to provider %q: aws_region and aws_profile are only used by providers that authenticate from the AWS credential chain (protocol %s)", field, providerName, llm.ProtocolAnthropicBedrock)
		}
		if field == "aws_region" {
			entry.AWSRegion = normalized
		} else {
			entry.AWSProfile = normalized
		}
	default:
		return fmt.Errorf("unknown provider field %q: supported fields are api_key, api_key_cmd, url, protocol, model, models, auth_header, extra_body, extra_headers, retry_codes, aws_region, aws_profile", field)
	}
	return nil
}

// providerAcceptsAWSSettings reports whether aws_region / aws_profile mean
// anything for this provider. Storing them anywhere else would be dead config
// that reads as applied, so it is rejected instead.
//
// The entry's own protocol decides whenever it sets one: a preset's protocol can
// be overridden per entry (see tryProviderConfig), so `protocol: openai` on the
// bedrock preset would otherwise still accept AWS settings that nothing reads.
// Only when the entry is silent does the preset's own AmbientAuth flag answer.
func providerAcceptsAWSSettings(providerName string, entry *ProviderEntry) bool {
	if entry.Protocol != "" {
		return llm.NormalizeProtocol(entry.Protocol) == llm.ProtocolAnthropicBedrock
	}
	preset, isPreset := llm.LookupProvider(providerName)
	return isPreset && preset.AmbientAuth

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Check the spelling against the supported list in the error message
  2. Run `ocr config --help` or consult docs for valid provider fields
  3. Map the intended setting: e.g. base_url -> url, apikey -> api_key

Example fix

// before
ocr config set custom_providers.foo.base_url https://api.example.com
// after
ocr config set custom_providers.foo.url https://api.example.com
Defensive patterns

Strategy: validation

Validate before calling

valid="api_key api_key_cmd url protocol model models auth_header extra_body extra_headers retry_codes aws_region aws_profile"
[[ " $valid " == *" $field "* ]] && ocr config set providers.foo."$field" "$value" || echo "unknown field: $field"

Prevention

When it happens

Trigger: `ocr config set providers.<name>.<field> <value>` where <field> is misspelled (e.g. 'apikey', 'base_url', 'endpoint') or simply does not exist.

Common situations: Recalling field names from another tool's config (base_url vs url, apikey vs api_key); typos like extra-header; copying examples from outdated documentation.

Related errors


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/f31e19b6607e1f1f. Report an issue: GitHub.