JuliusBrussee/caveman · error
cachebench: observation line
Error message
cachebench: observation line %d: trailing JSON
What it means
After decoding one observation record from a line, a second JSON value was still present (decoder did not hit EOF). Each JSONL line must contain exactly one object; concatenated objects are rejected as trailing JSON.
Solutions
- Split concatenated JSON values onto separate lines
- Regenerate the file with one record per line
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/observed.go:126 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/56cce490d13db7ef.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/observed.go:126
raw := bytes.TrimSpace(scanner.Bytes())
if len(raw) == 0 {
continue
}
if len(records) >= limits.MaxRecords {
return nil, fmt.Errorf("cachebench: observations exceed record limit %d", limits.MaxRecords)
}
if !validUniqueJSONObject(raw) {
return nil, fmt.Errorf("cachebench: observation line %d: duplicate or invalid JSON", line)
}
decoder := json.NewDecoder(bytes.NewReader(raw))
decoder.DisallowUnknownFields()
var record ObservationRecord
if err := decoder.Decode(&record); err != nil {
return nil, fmt.Errorf("cachebench: observation line %d: %w", line, err)
}
var trailing any
if err := decoder.Decode(&trailing); err != io.EOF {
return nil, fmt.Errorf("cachebench: observation line %d: trailing JSON", line)
}
if record.Schema != ObservationSchema {
return nil, fmt.Errorf("cachebench: observation line %d: schema %q", line, record.Schema)
}
if strings.TrimSpace(record.RequestID) == "" || seen[record.RequestID] {
return nil, fmt.Errorf("cachebench: observation line %d: empty or duplicate request_id", line)
}
seen[record.RequestID] = true
record.Usage = append(json.RawMessage(nil), record.Usage...)
records = append(records, record)
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("cachebench: read observations: %w", err)
}
if len(records) == 0 {
return nil, errors.New("cachebench: no observation records")
}
if err := validateObservationRecords(records); err != nil {View on GitHub (pinned to 766dce6b13)