JuliusBrussee/caveman · error

/ : invalid pricing

Error message

%s %s/%s: invalid pricing

What it means

Each entry's pricing object must pass cost.ValidPrice; otherwise DecodeAndValidate rejects the row. ValidPrice guards against negative, zero, or otherwise unsafe prices that would corrupt cost calculations.

Solutions

  1. Fix the numeric prices on the reported entry to valid positive rates (e.g. input/output per-token costs).
  2. Remove currency symbols/commas and ensure plain decimal numbers in YAML.
  3. Verify against the provider's public pricing page and update verified_at.
  4. Check cost.ValidPrice's rules to confirm the exact constraint being violated.

Example fix

# before
pricing:
  input: -0.01
# after
pricing:
  input: 0.003
  output: 0.015
Defensive patterns

Strategy: validation

Validate before calling

if !cost.ValidPrice(e.Pricing) {
	return fmt.Errorf("entry %s/%s has invalid pricing", e.Provider, e.Model)
}

Try / catch

if _, err := catalog.DecodeAndValidate(raw); err != nil {
	if strings.Contains(err.Error(), "invalid pricing") {
		return fmt.Errorf("correct prices per ValidPrice rules: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: DecodeAndValidate encounters an entry whose pricing values are negative, missing, or otherwise fail cost.ValidPrice (e.g. per-token rates below the allowed floor or malformed numbers).

Common situations: A price typed as -0.01 by mistake, prices pasted with currency symbols or commas ('1,50'), a zeroed placeholder row, or a schema change making an expected pricing field absent.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

		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)
			}
			if capVerified.After(time.Now().UTC().Add(24 * time.Hour)) {
				return nil, fmt.Errorf("%s %s/%s: capabilities_verified_at is in the future", label, entry.Provider, entry.Model)
			}
		}
		if len(entry.Sources) == 0 {

View on GitHub (pinned to 3ee70a1026)