{"record":{"id":"2930011661fb6663","repo":"JuliusBrussee/caveman","slug":"label-pricing-batch-discount-fraction-must-be","errorCode":null,"errorMessage":"{label}: pricing.batch_discount_fraction must be <= 1","messagePattern":"(.+?): pricing\\.batch_discount_fraction must be <= 1","errorType":"validation","errorClass":"CatalogError","httpStatus":null,"severity":"error","filePath":"shared/provider-catalog/validate_catalog.py","lineNumber":152,"sourceCode":"    if not isinstance(pricing, dict):\n        raise CatalogError(f\"{label}: pricing must be an object\")\n    pricing_unknown = set(pricing) - PRICING_KEYS\n    if pricing_unknown:\n        raise CatalogError(f\"{label}: unknown pricing field(s): {', '.join(sorted(pricing_unknown))}\")\n    for required in (\"input_per_million\", \"output_per_million\"):\n        if required not in pricing:\n            raise CatalogError(f\"{label}: pricing.{required} is required\")\n    for field, value in pricing.items():\n        if value is None or field == \"long_context_threshold_inclusive\":\n            if field == \"long_context_threshold_inclusive\" and value is not None and not isinstance(value, bool):\n                raise CatalogError(f\"{label}: pricing.{field} must be boolean or null\")\n            continue\n        if isinstance(value, bool) or not isinstance(value, (int, float)):\n            raise CatalogError(f\"{label}: pricing.{field} must be numeric or null\")\n        if not math.isfinite(value) or value < 0:\n            raise CatalogError(f\"{label}: pricing.{field} must be finite and nonnegative\")\n        if field == \"batch_discount_fraction\" and value > 1:\n            raise CatalogError(f\"{label}: pricing.batch_discount_fraction must be <= 1\")\n\n    if not isinstance(row[\"capabilities\"], dict):\n        raise CatalogError(f\"{label}: capabilities must be an object\")\n    sources = row[\"sources\"]\n    if not isinstance(sources, list) or not sources:\n        raise CatalogError(f\"{label}: sources must be a non-empty list\")\n    if any(not isinstance(source, str) or not source.startswith(\"https://\") for source in sources):\n        raise CatalogError(f\"{label}: every source must be HTTPS\")\n\n    verified_at = parsed_time(row[\"verified_at\"], label)\n    if verified_at > now:\n        raise CatalogError(f\"{label}: verified_at is in the future\")\n    if verified_at < now - timedelta(days=120):\n        raise CatalogError(f\"{label}: verified_at is older than 120 days\")\n    return identity[0], identity[1], identity[2]\n\n\ndef check_review_markers(text: str, label: str) -> None:","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/provider-catalog/validate_catalog.py#L134-L170","documentation":"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.","triggerScenarios":"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).","commonSituations":"Confusing percent with fraction notation; copying a percentage value from provider docs (\"50% batch discount\") directly into the field.","solutions":["Divide the percentage by 100 (50% becomes 0.5)","Confirm the intended value is a fraction in [0, 1] and set it accordingly","If you truly mean a >100% discount, that is invalid — recheck the provider's docs"],"exampleFix":"// before\npricing:\n  batch_discount_fraction: 50\n// after\npricing:\n  batch_discount_fraction: 0.5","handlingStrategy":"validation","validationCode":"d = pricing.get(\"batch_discount_fraction\")\nassert d is None or (isinstance(d, (int, float)) and 0 <= d <= 1)","typeGuard":"def is_valid_fraction(v):\n    return v is None or (isinstance(v, (int, float)) and not isinstance(v, bool) and 0 <= v <= 1)","tryCatchPattern":"try:\n    validate_catalog(rows)\nexcept CatalogError as e:\n    if \"batch_discount_fraction\" in str(e):\n        pricing[\"batch_discount_fraction\"] /= 100\n    raise","preventionTips":["Remember the field is a fraction, not a percentage","Divide provider percentages by 100 on import","Schema-check with maximum: 1"],"tags":["validation","pricing","range","units"],"backgroundTag":"value-out-of-range","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}