alibaba/open-code-review · error

provider %q is not configured; set a core field first (proto

Error message

provider %q is not configured; set a core field first (protocol is required for every custom provider):
  ocr config set %s.protocol <protocol>

What it means

Auxiliary provider fields (anything other than core fields like protocol) cannot be the first thing set for a custom provider: the entry must already exist in cfg.CustomProviders. This forces the user to establish the provider with a core field (protocol is mandatory) before adding optional settings, so the protocol is known before auxiliary validation.

Source

Thrown at cmd/opencodereview/config_cmd.go:831

	if preset, isPreset := llm.LookupProvider(parts[1]); isPreset {
		return fmt.Errorf("custom provider name %q conflicts with a preset provider; use providers.%s.%s to configure the preset or choose a different custom provider name", parts[1], preset.Name, parts[2])
	}
	return setCustomProviderField(cfg, parts[1], parts[2], key, value)
}

func isAuxiliaryProviderField(field string) bool {
	switch field {
	case "extra_body", "extra_headers", "retry_codes":
		return true
	default:
		return false
	}
}

func setCustomProviderField(cfg *Config, name, field, key, value string) error {
	if _, exists := cfg.CustomProviders[name]; isAuxiliaryProviderField(field) && !exists {
		providerKey := strings.TrimSuffix(key, "."+field)
		return fmt.Errorf("provider %q is not configured; set a core field first (protocol is required for every custom provider):\n  ocr config set %s.protocol <protocol>", name, providerKey)
	}
	if cfg.CustomProviders == nil {
		cfg.CustomProviders = make(map[string]ProviderEntry)
	}
	entry := cfg.CustomProviders[name]
	if err := applyProviderField(name, &entry, field, key, value); err != nil {
		return err
	}
	cfg.CustomProviders[name] = entry
	return nil
}

func setMCPServerValue(cfg *Config, key, value string) error {
	parts := strings.SplitN(key, ".", 3)
	if len(parts) != 3 || parts[1] == "" || parts[2] == "" {
		return fmt.Errorf("invalid MCP server key %q: expected mcp_servers.<name>.<field>", key)
	}
	name, field := parts[1], parts[2]

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. First set a core field, e.g. ocr config set custom_providers.<name>.protocol <protocol>
  2. Verify the provider name spelling matches an already-configured custom provider
  3. Then re-run the auxiliary field setting (extra_headers, retry_codes, aws_*, etc.)

Example fix

// before
ocr config set custom_providers.newprov.retry_codes "429"
// after
ocr config set custom_providers.newprov.protocol openai
ocr config set custom_providers.newprov.retry_codes "429"
Defensive patterns

Strategy: validation

Validate before calling

name="newprovider"
ocr config get custom_providers."$name".protocol >/dev/null 2>&1 || ocr config set custom_providers."$name".protocol openai

Try / catch

if _, exists := cfg.CustomProviders[name]; isAuxiliaryProviderField(field) && !exists {
    return fmt.Errorf("provider %q is not configured; set a core field first", name)
}

Prevention

When it happens

Trigger: `ocr config set custom_providers.newprovider.extra_headers 'X: y'` where custom_providers.newprovider has never been created (no core field set yet).

Common situations: Skipping straight to tweaking retries/headers on a brand-new custom provider; following documentation that omits the protocol step; a typo in the provider name that matches no existing entry.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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