{"record":{"id":"3e019e5631c1742d","repo":"JuliusBrussee/caveman","slug":"usage-export-has-no-recognizable-token-columns-sa","errorCode":null,"errorMessage":"usage export has no recognizable token columns (saw: %s)","messagePattern":"usage export has no recognizable token columns \\(saw: (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/learn_reconcile.go","lineNumber":112,"sourceCode":"\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}\n\traw := strings.TrimSpace(strings.ReplaceAll(record[index], \",\", \"\"))\n\tif raw == \"\" {\n\t\treturn 0\n\t}\n\tvalue, err := strconv.ParseFloat(raw, 64)\n\tif err != nil || value < 0 {\n\t\treturn 0\n\t}\n\treturn int64(value)","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/store/learn_reconcile.go#L94-L130","documentation":"After requiring a model column, mapReconcileHeader requires at least one recognized token column (input, output, cache_read, cache_write or their aliases). With zero token columns reconciliation has nothing to sum, so it fails closed and echoes the original header.","triggerScenarios":"parseUsageExport on a CSV whose header has a model column but none of the token-count columns (e.g. only cost or request-count columns).","commonSituations":"Exporting a spend-only report instead of a token usage report; provider renaming token columns beyond the alias set; trimming the CSV to remove 'unused' token columns.","solutions":["Include at least one token column (input/output/cache_read/cache_write or a recognized alias) in the export","Re-export the full usage report rather than a cost summary","Add the new column alias to the token matcher in mapReconcileHeader if the provider renamed it"],"exampleFix":"// before\nmodel,total_cost\ngpt-4o,1.23\n// after\nmodel,input_tokens,output_tokens,total_cost\ngpt-4o,1000,200,1.23","handlingStrategy":"validation","validationCode":"header, _ := firstCsvLine(path); need := []string{\"input\",\"output\",\"cache_read\",\"cache_write\"}; if !anyAliasPresent(header, need) { return fmt.Errorf(\"usage export missing token columns\") }","typeGuard":null,"tryCatchPattern":"if _, err := store.BuildLearnReconcile(ctx, opts); err != nil { if strings.Contains(err.Error(), \"no recognizable token columns\") { log.Error(\"export lacks input/output token columns\") } }","preventionTips":["Export the full token-usage report, not cost summaries","Check the export includes per-model token counts before reconciling","Extend the alias table when adopting a new provider"],"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"}