{"record":{"id":"c1729b4aac739279","repo":"JuliusBrussee/caveman","slug":"label-pricing-field-must-be-numeric-or-null","errorCode":null,"errorMessage":"{label}: pricing.{field} must be numeric or null","messagePattern":"(.+?): pricing\\.(.+?) must be numeric or null","errorType":"validation","errorClass":"CatalogError","httpStatus":null,"severity":"error","filePath":"shared/provider-catalog/validate_catalog.py","lineNumber":148,"sourceCode":"    if row[\"currency\"] != \"USD\":\n        raise CatalogError(f\"{label}: currency must be USD\")\n\n    pricing = row[\"pricing\"]\n    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\")","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/provider-catalog/validate_catalog.py#L130-L166","documentation":"Every non-boolean pricing field (input_per_million, output_per_million, cache_read/write multipliers, batch_discount_fraction, etc.) must be numeric (int/float) or null. Strings, dicts, lists, or booleans raise this CatalogError; booleans are explicitly rejected because bool is a subclass of int in Python.","triggerScenarios":"A pricing field like input_per_million is set to \"3.0\" (string), true, or a nested object; a numeric field received a bool from a transform script.","commonSituations":"Prices quoted in YAML (\"3.0\" instead of 3.0); CSV imports delivering prices as strings; templating that stringifies numbers; JSON Schema edits putting objects where numbers belong.","solutions":["Convert the value to an unquoted number (e.g. 3.0 not \"3.0\")","Use null if the price is genuinely unknown/not applicable","Check upstream import/transform code that the value isn't passed as str or bool"],"exampleFix":"// before\npricing:\n  input_per_million: \"3.0\"\n// after\npricing:\n  input_per_million: 3.0","handlingStrategy":"type-guard","validationCode":"for k, v in pricing.items():\n    if k == \"long_context_threshold_inclusive\":\n        continue\n    assert v is None or (isinstance(v, (int, float)) and not isinstance(v, bool)), k","typeGuard":"def is_num_or_none(v):\n    return v is None or (isinstance(v, (int, float)) and not isinstance(v, bool))","tryCatchPattern":"try:\n    validate_catalog(rows)\nexcept CatalogError as e:\n    if \"must be numeric or null\" in str(e):\n        coerce_pricing_numbers(rows)\n    raise","preventionTips":["Unquote numbers in YAML/JSON","Cast to float() at import boundaries","Reject bools explicitly (bool is an int subclass in Python)"],"tags":["validation","type-error","pricing","numeric"],"backgroundTag":"type-mismatch","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"}