{"record":{"id":"a4c522b56ebb7629","repo":"JuliusBrussee/caveman","slug":"label-unknown-pricing-field-s-join-sort","errorCode":null,"errorMessage":"{label}: unknown pricing field(s): {', '.join(sorted(pricing_unknown))}","messagePattern":"(.+?): unknown pricing field\\(s\\): (.+?)","errorType":"validation","errorClass":"CatalogError","httpStatus":null,"severity":"error","filePath":"shared/provider-catalog/validate_catalog.py","lineNumber":138,"sourceCode":"        raise CatalogError(f\"{label}: unknown field(s): {', '.join(sorted(unknown))}\")\n    if missing:\n        raise CatalogError(f\"{label}: missing field(s): {', '.join(sorted(missing))}\")\n\n    identity: list[str] = []\n    for field in (\"provider\", \"model\", \"region\"):\n        value = row[field]\n        if not isinstance(value, str) or not IDENTIFIER.fullmatch(value):\n            raise CatalogError(f\"{label}: {field} must be a safe non-empty identifier\")\n        identity.append(value)\n    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\"]","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/provider-catalog/validate_catalog.py#L120-L156","documentation":"The `pricing` object contains a key outside the allowlisted PRICING_KEYS set (the twelve known per-million rate/threshold fields). Like the top-level schema, pricing is strict-allowlist so misspelled or invented rate names cannot silently produce zero-cost math. Thrown from validate_row.","triggerScenarios":"pricing has keys like `input_per_million_tokens`, `inputPerMillion`, `output`, `cache_read`, or a renamed/typo'd variant of an allowed key, making `set(pricing) - PRICING_KEYS` non-empty.","commonSituations":"Typo in an allowed key name; a script using camelCase or a third-party API's field names; inventing a new pricing field without registering it in PRICING_KEYS and schemas/provider-catalog.schema.json; copying field names from a provider's API docs instead of this schema.","solutions":["Rename the listed key(s) to the exact allowed names (e.g. `input_per_million`, `output_per_million`, `cache_read_input_per_million`)","Check PRICING_KEYS in validate_catalog.py for the exact spelling of each field","If a genuinely new pricing field is needed, add it to PRICING_KEYS and schemas/provider-catalog.schema.json in the same PR","Map third-party field names to the schema's snake_case names in any sync script"],"exampleFix":"# before\npricing:\n  input_per_million_tokens: 2.5\n\n# after\npricing:\n  input_per_million: 2.5","handlingStrategy":"validation","validationCode":"PRICING_KEYS = {\"input_per_million\",\"output_per_million\",\"cache_read_input_per_million\",\"cache_write_input_per_million\",\"cache_write_1h_input_per_million\",\"reasoning_output_per_million\",\"batch_discount_fraction\",\"cache_storage_per_million_tokens_hour\",\"long_context_threshold_tokens\",\"long_context_threshold_inclusive\",\"long_context_input_multiplier\",\"long_context_output_multiplier\"}\n\ndef pricing_keys_ok(row: dict) -> bool:\n    p = row.get(\"pricing\")\n    return isinstance(p, dict) and not (set(p) - PRICING_KEYS)","typeGuard":"def has_known_pricing_keys(pricing: dict) -> bool:\n    return set(pricing).issubset(PRICING_KEYS)","tryCatchPattern":"try:\n    validate_catalog()\nexcept CatalogError as e:\n    if \"unknown pricing field(s)\" in str(e):\n        rename_pricing_keys(str(e))","preventionTips":["Copy key names verbatim from an existing row or PRICING_KEYS","Map third-party/camelCase names to schema names in sync scripts","Validate against schemas/provider-catalog.schema.json which lists the same allowed pricing keys"],"tags":["schema-validation","yaml","pricing","catalog"],"backgroundTag":"schema-validation-failed","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"}