{"record":{"id":"2b54d31f94774cd7","repo":"JuliusBrussee/caveman","slug":"s-s-s-invalid-pricing","errorCode":null,"errorMessage":"%s %s/%s: invalid pricing","messagePattern":"(.+?) (.+?)/(.+?): invalid pricing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/catalog/catalog.go","lineNumber":329,"sourceCode":"\t\tif err == nil {\n\t\t\treturn nil, fmt.Errorf(\"multiple YAML documents are not allowed\")\n\t\t}\n\t\treturn nil, err\n\t}\n\tif len(decoded) == 0 {\n\t\treturn nil, fmt.Errorf(\"catalog is empty\")\n\t}\n\tseen := make(map[string]struct{}, len(decoded))\n\tfor i, entry := range decoded {\n\t\tlabel := fmt.Sprintf(\"entry %d\", i)\n\t\tif strings.TrimSpace(entry.Provider) == \"\" || strings.TrimSpace(entry.Model) == \"\" || strings.TrimSpace(entry.Region) == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"%s: provider, model, and region are required\", label)\n\t\t}\n\t\tif entry.Currency != \"USD\" {\n\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: unsupported currency %q\", label, entry.Provider, entry.Model, entry.Currency)\n\t\t}\n\t\tif !cost.ValidPrice(entry.Pricing) {\n\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: invalid pricing\", label, entry.Provider, entry.Model)\n\t\t}\n\t\tverified, err := time.Parse(time.RFC3339, entry.VerifiedAt)\n\t\tif err != nil || verified.IsZero() {\n\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: verified_at must be RFC3339\", label, entry.Provider, entry.Model)\n\t\t}\n\t\tif verified.After(time.Now().UTC().Add(24 * time.Hour)) {\n\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: verified_at is in the future\", label, entry.Provider, entry.Model)\n\t\t}\n\t\tif entry.CapabilitiesVerifiedAt != \"\" {\n\t\t\tcapVerified, err := time.Parse(time.RFC3339, entry.CapabilitiesVerifiedAt)\n\t\t\tif err != nil || capVerified.IsZero() {\n\t\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: capabilities_verified_at must be RFC3339\", label, entry.Provider, entry.Model)\n\t\t\t}\n\t\t\tif capVerified.After(time.Now().UTC().Add(24 * time.Hour)) {\n\t\t\t\treturn nil, fmt.Errorf(\"%s %s/%s: capabilities_verified_at is in the future\", label, entry.Provider, entry.Model)\n\t\t\t}\n\t\t}\n\t\tif len(entry.Sources) == 0 {","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/catalog/catalog.go#L311-L347","documentation":"Each entry's pricing object must pass cost.ValidPrice; otherwise DecodeAndValidate rejects the row. ValidPrice guards against negative, zero, or otherwise unsafe prices that would corrupt cost calculations.","triggerScenarios":"DecodeAndValidate encounters an entry whose pricing values are negative, missing, or otherwise fail cost.ValidPrice (e.g. per-token rates below the allowed floor or malformed numbers).","commonSituations":"A price typed as -0.01 by mistake, prices pasted with currency symbols or commas ('1,50'), a zeroed placeholder row, or a schema change making an expected pricing field absent.","solutions":["Fix the numeric prices on the reported entry to valid positive rates (e.g. input/output per-token costs).","Remove currency symbols/commas and ensure plain decimal numbers in YAML.","Verify against the provider's public pricing page and update verified_at.","Check cost.ValidPrice's rules to confirm the exact constraint being violated."],"exampleFix":"# before\npricing:\n  input: -0.01\n# after\npricing:\n  input: 0.003\n  output: 0.015","handlingStrategy":"validation","validationCode":"if !cost.ValidPrice(e.Pricing) {\n\treturn fmt.Errorf(\"entry %s/%s has invalid pricing\", e.Provider, e.Model)\n}","typeGuard":null,"tryCatchPattern":"if _, err := catalog.DecodeAndValidate(raw); err != nil {\n\tif strings.Contains(err.Error(), \"invalid pricing\") {\n\t\treturn fmt.Errorf(\"correct prices per ValidPrice rules: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Enter prices as plain YAML decimals — no symbols, commas, or negatives","Cross-check prices against the provider's pricing page before commit","Add a unit test that runs ValidPrice over the whole catalog"],"tags":["catalog","pricing","validation"],"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"}