{"record":{"id":"4467cbc4a542316f","repo":"JuliusBrussee/caveman","slug":"usage-export-has-no-header-row-w","errorCode":null,"errorMessage":"usage export has no header row: %w","messagePattern":"usage export has no header row: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/learn_reconcile.go","lineNumber":144,"sourceCode":"\tvalue, err := strconv.ParseFloat(raw, 64)\n\tif err != nil || value < 0 {\n\t\treturn 0\n\t}\n\treturn int64(value)\n}\n\n// parseUsageExport reads a provider usage CSV into billed tokens per model.\nfunc parseUsageExport(path string) (map[string]int64, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read usage export: %w\", err)\n\t}\n\tdefer file.Close()\n\treader := csv.NewReader(file)\n\treader.FieldsPerRecord = -1\n\theader, err := reader.Read()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"usage export has no header row: %w\", err)\n\t}\n\tcolumns, err := mapReconcileHeader(header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbilled := map[string]int64{}\n\tfor {\n\t\trecord, err := reader.Read()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"usage export row: %w\", err)\n\t\t}\n\t\tmodelIndex := columns[\"model\"]\n\t\tif modelIndex >= len(record) {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/81536f57b3303b7de7f5bc5b564cc344f9112d68/proxy/internal/store/learn_reconcile.go#L126-L162","documentation":"The csv.Reader returned an error on its first Read in parseUsageExport, meaning the file has no parseable header row — typically an empty file or unreadable/binary content. The wrapped error carries the CSV parser's reason.","triggerScenarios":"Thrown at proxy/internal/store/learn_reconcile.go:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the usage export file is a non-empty CSV with a header row","Re-export from the provider; the file may be truncated or empty","Ensure the path points to the CSV, not a directory or binary file"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81536f57b3303b7de7f5bc5b564cc344f9112d68","analyzedAt":"2026-08-27T02:25:50.681Z","contentChangedAt":"2026-08-27T02:25:50.681Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}