JuliusBrussee/caveman · error · CatalogError

: pricing.batch_discount_fraction must be <= 1

Error message

{label}: pricing.batch_discount_fraction must be <= 1

What it means

CatalogError from validate_row: the pricing block declares a batch_discount_fraction greater than 1, i.e. a discount over 100% of the price, which is nonsensical pricing data. The row label prefixes the message so the offending catalog entry is identifiable.

Solutions

  1. Divide the percentage by 100 (50% becomes 0.5)
  2. Confirm the intended value is a fraction in [0, 1] and set it accordingly
  3. If you truly mean a >100% discount, that is invalid — recheck the provider's docs

Example fix

// before
pricing:
  batch_discount_fraction: 50
// after
pricing:
  batch_discount_fraction: 0.5
Defensive patterns

Strategy: validation

Validate before calling

d = pricing.get("batch_discount_fraction")
assert d is None or (isinstance(d, (int, float)) and 0 <= d <= 1)

Type guard

def is_valid_fraction(v):
    return v is None or (isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v <= 1)

Try / catch

try:
    validate_catalog(rows)
except CatalogError as e:
    if "batch_discount_fraction" in str(e):
        pricing["batch_discount_fraction"] /= 100
    raise

Prevention

When it happens

Trigger: pricing.batch_discount_fraction set to e.g. 50 or 1.5 — entering the discount as a percentage (50 for 50%) instead of a fraction (0.5).

Common situations: Confusing percent with fraction notation; copying a percentage value from provider docs ("50% batch discount") directly into the field.

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/2930011661fb6663. Report an issue: GitHub.

Appendix: source

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

    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):
        raise CatalogError(f"{label}: every source must be HTTPS")

    verified_at = parsed_time(row["verified_at"], label)
    if verified_at > now:
        raise CatalogError(f"{label}: verified_at is in the future")
    if verified_at < now - timedelta(days=120):
        raise CatalogError(f"{label}: verified_at is older than 120 days")
    return identity[0], identity[1], identity[2]


def check_review_markers(text: str, label: str) -> None:

View on GitHub (pinned to 3ee70a1026)