{"record":{"id":"c5f99fea5897693a","repo":"JuliusBrussee/caveman","slug":"usage-export-has-no-recognizable-model-column-saw","errorCode":null,"errorMessage":"usage export has no recognizable model column (saw: %s)","messagePattern":"usage export has no recognizable model column \\(saw: (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/learn_reconcile.go","lineNumber":103,"sourceCode":"// least one token column is the minimum; anything less cannot be reconciled.\nfunc mapReconcileHeader(header []string) (map[string]int, error) {\n\tfound := map[string]int{}\n\tfor index, raw := range header {\n\t\tnormalized := normalizeHeader(raw)\n\t\tfor field, aliases := range reconcileColumns {\n\t\t\tif _, taken := found[field]; taken {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, alias := range aliases {\n\t\t\t\tif normalized == normalizeHeader(alias) {\n\t\t\t\t\tfound[field] = index\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif _, ok := found[\"model\"]; !ok {\n\t\treturn nil, fmt.Errorf(\"usage export has no recognizable model column (saw: %s)\", strings.Join(header, \", \"))\n\t}\n\ttokenFields := 0\n\tfor _, field := range []string{\"input\", \"output\", \"cache_read\", \"cache_write\"} {\n\t\tif _, ok := found[field]; ok {\n\t\t\ttokenFields++\n\t\t}\n\t}\n\tif tokenFields == 0 {\n\t\treturn nil, fmt.Errorf(\"usage export has no recognizable token columns (saw: %s)\", strings.Join(header, \", \"))\n\t}\n\treturn found, nil\n}\n\nfunc reconcileCell(record []string, columns map[string]int, field string) int64 {\n\tindex, ok := columns[field]\n\tif !ok || index >= len(record) {\n\t\treturn 0\n\t}","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/store/learn_reconcile.go#L85-L121","documentation":"mapReconcileHeader maps a provider usage-export CSV header to canonical fields using fuzzy aliases. If no column matches the known 'model' aliases it fails closed so reconciliation cannot silently mis-attribute tokens, listing the raw header in the message.","triggerScenarios":"parseUsageExport reading a CSV whose header row lacks any recognized model column variant (e.g. renamed to something not in the alias list, or header in another language).","commonSituations":"Provider changed their usage-export column names; hand-made CSV missing a model column; exporting a non-usage report (e.g. invoices) and pointing reconcile at it.","solutions":["Export a usage CSV that includes a model column (any recognized alias: model, Model, model_name, etc.)","Check the header spelling against the aliases in mapReconcileHeader and fix the CSV","If it's a new provider naming, add the alias to the model matcher in mapReconcileHeader"],"exampleFix":"// before\ntokens,cost\n... // no model column\n// after\nmodel,tokens,cost\ngpt-4o,1234,0.01","handlingStrategy":"validation","validationCode":"header, _ := firstCsvLine(path); if !strings.Contains(strings.ToLower(header), \"model\") { return fmt.Errorf(\"usage export missing model column\") }","typeGuard":null,"tryCatchPattern":"if _, err := store.BuildLearnReconcile(ctx, opts); err != nil { if strings.Contains(err.Error(), \"no recognizable model column\") { log.Error(\"unsupported export schema; expected a model column, saw: \", headerPart) } }","preventionTips":["Validate the export header after every download from the provider","Keep a golden sample CSV and smoke-test parsing in CI","When providers rename columns, add aliases before shipping"],"tags":["csv","schema","validation","learn"],"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"}