JuliusBrussee/caveman · error · CatalogError

: pricing. is required

Error message

{label}: pricing.{required} is required

What it means

validate_row enforces that each catalog row's pricing object carries the two required cost keys: 'input_per_million' and 'output_per_million'. If either key is absent from the pricing dict, the catalog cannot compute per-token costs, so validation fails with this CatalogError. The {label} prefix identifies which row failed.

Solutions

  1. Add the missing 'input_per_million' and/or 'output_per_million' key to the row's pricing object with a finite nonnegative number (cost in currency per 1M tokens)
  2. Diff the row against a sibling row of the same provider to spot the dropped key
  3. If the model is free, set the key explicitly to 0 rather than omitting it
  4. Re-run validate_catalog to confirm the row passes

Example fix

// before
pricing:
  input_per_million: 3.0
// after
pricing:
  input_per_million: 3.0
  output_per_million: 15.0
Defensive patterns

Strategy: validation

Validate before calling

def has_required_pricing(pricing):
    return isinstance(pricing, dict) and "input_per_million" in pricing and "output_per_million" in pricing

Type guard

def is_valid_pricing(p):
    return isinstance(p, dict) and all(k in p for k in ("input_per_million", "output_per_million"))

Try / catch

try:
    validate_catalog(rows)
except CatalogError as e:
    print(f"fix catalog row: {e}")

Prevention

When it happens

Trigger: A catalog row's pricing object omits 'input_per_million' or 'output_per_million' (e.g. pricing only has {"batch_discount_fraction": 0.5} or is missing one direction of the pricing).

Common situations: Hand-editing a provider catalog YAML/JSON and dropping a key; adding a new model row with a partially filled pricing block; a sync/merge tool writing partial pricing objects; copying a row and deleting a key that looked redundant.

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 JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/9c0b36d0083929bd. Report an issue: GitHub.

Appendix: source

Thrown at shared/provider-catalog/validate_catalog.py:141

    identity: list[str] = []
    for field in ("provider", "model", "region"):
        value = row[field]
        if not isinstance(value, str) or not IDENTIFIER.fullmatch(value):
            raise CatalogError(f"{label}: {field} must be a safe non-empty identifier")
        identity.append(value)
    if row["currency"] != "USD":
        raise CatalogError(f"{label}: currency must be USD")

    pricing = row["pricing"]
    if not isinstance(pricing, dict):
        raise CatalogError(f"{label}: pricing must be an object")
    pricing_unknown = set(pricing) - PRICING_KEYS
    if pricing_unknown:
        raise CatalogError(f"{label}: unknown pricing field(s): {', '.join(sorted(pricing_unknown))}")
    for required in ("input_per_million", "output_per_million"):
        if required not in pricing:
            raise CatalogError(f"{label}: pricing.{required} is required")
    for field, value in pricing.items():
        if value is None or field == "long_context_threshold_inclusive":
            if field == "long_context_threshold_inclusive" and value is not None and not isinstance(value, bool):
                raise CatalogError(f"{label}: pricing.{field} must be boolean or null")
            continue
        if isinstance(value, bool) or not isinstance(value, (int, float)):
            raise CatalogError(f"{label}: pricing.{field} must be numeric or null")
        if not math.isfinite(value) or value < 0:
            raise CatalogError(f"{label}: pricing.{field} must be finite and nonnegative")
        if field == "batch_discount_fraction" and value > 1:
            raise CatalogError(f"{label}: pricing.batch_discount_fraction must be <= 1")

    if not isinstance(row["capabilities"], dict):
        raise CatalogError(f"{label}: capabilities must be an object")
    sources = row["sources"]
    if not isinstance(sources, list) or not sources:
        raise CatalogError(f"{label}: sources must be a non-empty list")
    if any(not isinstance(source, str) or not source.startswith("https://") for source in sources):

View on GitHub (pinned to 3ee70a1026)