JuliusBrussee/caveman · error

: provider, model, and region are required

Error message

%s: provider, model, and region are required

What it means

Every catalog entry must have non-blank provider, model, and region fields; DecodeAndValidate labels the failing row ('entry N') and rejects it. Blank/whitespace-only values would create ambiguous routing rows.

Solutions

  1. Set non-empty values for provider, model, and region on the entry number reported.
  2. Trim whitespace — a value of only spaces is treated as missing.
  3. Check for unrendered template placeholders and run the template step.
  4. Run the catalog test suite before committing the file.

Example fix

# before
- provider: ""
  model: claude-sonnet
  region: us
# after
- provider: anthropic
  model: claude-sonnet
  region: us
Defensive patterns

Strategy: validation

Validate before calling

for i, e := range entries {
	if strings.TrimSpace(e.Provider) == "" || strings.TrimSpace(e.Model) == "" || strings.TrimSpace(e.Region) == "" {
		return fmt.Errorf("entry %d missing provider/model/region", i)
	}
}

Try / catch

if _, err := catalog.DecodeAndValidate(raw); err != nil {
	if strings.Contains(err.Error(), "required") {
		return fmt.Errorf("fix blank row: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: DecodeAndValidate (via load/loadCurrentCatalog/snapshotDrift) encounters an entry where provider, model, or region is missing, empty, or only whitespace (e.g. 'provider: ""' or 'provider: " "').

Common situations: Hand-added YAML rows missing a field, template placeholders left unrendered ('provider: ${PROVIDER}'), or rows copied from a schema where the field was renamed.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/dcb7f549a73d9f6b. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/catalog/catalog.go:323

	var decoded []Entry
	if err := dec.Decode(&decoded); err != nil {
		return nil, err
	}
	var trailing any
	if err := dec.Decode(&trailing); err != io.EOF {
		if err == nil {
			return nil, fmt.Errorf("multiple YAML documents are not allowed")
		}
		return nil, err
	}
	if len(decoded) == 0 {
		return nil, fmt.Errorf("catalog is empty")
	}
	seen := make(map[string]struct{}, len(decoded))
	for i, entry := range decoded {
		label := fmt.Sprintf("entry %d", i)
		if strings.TrimSpace(entry.Provider) == "" || strings.TrimSpace(entry.Model) == "" || strings.TrimSpace(entry.Region) == "" {
			return nil, fmt.Errorf("%s: provider, model, and region are required", label)
		}
		if entry.Currency != "USD" {
			return nil, fmt.Errorf("%s %s/%s: unsupported currency %q", label, entry.Provider, entry.Model, entry.Currency)
		}
		if !cost.ValidPrice(entry.Pricing) {
			return nil, fmt.Errorf("%s %s/%s: invalid pricing", label, entry.Provider, entry.Model)
		}
		verified, err := time.Parse(time.RFC3339, entry.VerifiedAt)
		if err != nil || verified.IsZero() {
			return nil, fmt.Errorf("%s %s/%s: verified_at must be RFC3339", label, entry.Provider, entry.Model)
		}
		if verified.After(time.Now().UTC().Add(24 * time.Hour)) {
			return nil, fmt.Errorf("%s %s/%s: verified_at is in the future", label, entry.Provider, entry.Model)
		}
		if entry.CapabilitiesVerifiedAt != "" {
			capVerified, err := time.Parse(time.RFC3339, entry.CapabilitiesVerifiedAt)
			if err != nil || capVerified.IsZero() {
				return nil, fmt.Errorf("%s %s/%s: capabilities_verified_at must be RFC3339", label, entry.Provider, entry.Model)

View on GitHub (pinned to 3ee70a1026)