JuliusBrussee/caveman · error
read usage export: %w
Error message
read usage export: %w
What it means
parseUsageExport wraps errors from opening the provider usage CSV file. If the export path is unreadable (missing file, permissions), the reconcile cannot compare billed tokens and fails with this wrapped cause.
Source
Thrown at proxy/internal/store/learn_reconcile.go:137
if !ok || index >= len(record) {
return 0
}
raw := strings.TrimSpace(strings.ReplaceAll(record[index], ",", ""))
if raw == "" {
return 0
}
value, err := strconv.ParseFloat(raw, 64)
if err != nil || value < 0 {
return 0
}
return int64(value)
}
// parseUsageExport reads a provider usage CSV into billed tokens per model.
func parseUsageExport(path string) (map[string]int64, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("read usage export: %w", err)
}
defer file.Close()
reader := csv.NewReader(file)
reader.FieldsPerRecord = -1
header, err := reader.Read()
if err != nil {
return nil, fmt.Errorf("usage export has no header row: %w", err)
}
columns, err := mapReconcileHeader(header)
if err != nil {
return nil, err
}
billed := map[string]int64{}
for {
record, err := reader.Read()
if err == io.EOF {
break
}View on GitHub (pinned to 81536f57b3)
Solutions
- Verify the usage-export path passed to caveman learn reconcile is correct
- Check the file exists and is readable by the current user
- Re-export the usage CSV from the provider if it was deleted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at proxy/internal/store/learn_reconcile.go:137 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@81536f57b3 (2026-08-27).
Data as JSON: /api/errors/359f9ea2e673bcc9.
Report an issue: GitHub.