JuliusBrussee/caveman · error

/ : unsupported currency

Error message

%s %s/%s: unsupported currency %q

What it means

Catalog validation error from DecodeAndValidate: a pricing entry declares a currency the platform does not support. The entry is labeled provider/model/region so the offending row is identifiable; unsupported currencies would break cost math downstream.

Solutions

  1. Set currency: USD on the reported entry.
  2. Convert the source prices to USD (at a documented rate) and record verification in verified_at/sources.
  3. Check casing — only the exact string 'USD' is accepted.
  4. If multi-currency support is needed, extend the library rather than smuggling other codes in.

Example fix

# before
currency: eur
# after
currency: USD
Defensive patterns

Strategy: validation

Validate before calling

if e.Currency != "USD" {
	return fmt.Errorf("currency must be USD, got %q", e.Currency)
}

Try / catch

if _, err := catalog.DecodeAndValidate(raw); err != nil {
	if strings.Contains(err.Error(), "unsupported currency") {
		return fmt.Errorf("convert prices to USD before ingest: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: DecodeAndValidate sees an entry whose currency field is not exactly 'USD' (e.g. 'EUR', 'eur', 'usd', or empty).

Common situations: Entries imported from a European or regional price list without conversion, lowercase currency codes from another tool, or a currency field accidentally dropped during editing.

Related errors


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

Appendix: source

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

	}
	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)
			}
			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)

View on GitHub (pinned to 3ee70a1026)