JuliusBrussee/caveman · error
cachebench: trace line %d: duplicate or invalid JSON
Error message
cachebench: trace line %d: duplicate or invalid JSON
What it means
Error "cachebench: trace line %d: duplicate or invalid JSON" thrown in JuliusBrussee/caveman.
Source
Thrown at cacheengine/cachebench/trace.go:300
}
scanner := bufio.NewScanner(reader)
initial := 64 * 1024
if limits.MaxLineBytes < initial {
initial = limits.MaxLineBytes
}
scanner.Buffer(make([]byte, initial), limits.MaxLineBytes)
seen := map[string]bool{}
var records []TraceRecord
for line := 1; scanner.Scan(); line++ {
raw := bytes.TrimSpace(scanner.Bytes())
if len(raw) == 0 {
continue
}
if len(records) >= limits.MaxRecords {
return nil, fmt.Errorf("cachebench: trace exceeds record limit %d", limits.MaxRecords)
}
if !validUniqueJSONObject(raw) {
return nil, fmt.Errorf("cachebench: trace line %d: duplicate or invalid JSON", line)
}
decoder := json.NewDecoder(bytes.NewReader(raw))
decoder.DisallowUnknownFields()
var record TraceRecord
if err := decoder.Decode(&record); err != nil {
return nil, fmt.Errorf("cachebench: trace line %d: %w", line, err)
}
var trailing any
if err := decoder.Decode(&trailing); err != io.EOF {
return nil, fmt.Errorf("cachebench: trace line %d: trailing JSON", line)
}
if record.Schema != TraceSchema && record.Schema != TraceSchemaV2 && record.Schema != TraceSchemaV1 || !validBoundedText(record.RequestID, 512, false) || seen[record.RequestID] {
return nil, fmt.Errorf("cachebench: trace line %d: invalid schema or request_id", line)
}
if _, err := time.Parse(time.RFC3339Nano, record.At); err != nil || !validTraceIdentity(record) || record.PrefixTokens < 0 {
return nil, fmt.Errorf("cachebench: trace line %d: incomplete request identity", line)
}
if len(record.Body) > limits.MaxBodyBytes || !json.Valid(record.Body) || record.BodySHA256 == "" || record.BodySHA256 != bodyDigest(record.Body) {View on GitHub (pinned to 27d5a3981a)
Solutions
- Fix duplicate keys or invalid JSON on the trace line.
When it happens
Trigger: Thrown at cacheengine/cachebench/trace.go:300 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/fe703a2cfab356ce.
Report an issue: GitHub.