JuliusBrussee/caveman · error
cachebench: trace request %q has invalid identity, body, or
Error message
cachebench: trace request %q has invalid identity, body, or digest
What it means
A trace record failed one of the identity/body checks: Provider or Epoch blank, Body not a valid unique JSON object, BodySHA256 empty, or BodySHA256 not equal to bodyDigest(Body). The digest check guarantees the recorded body is byte-faithful, which the evidence chain in the report relies on.
Source
Thrown at cacheengine/cachebench/observed.go:49
// EvaluateObservedAgainstTrace requires exact request population and body joins.
func EvaluateObservedAgainstTrace(records []ObservationRecord, trace []TraceRecord, target Target) (Report, error) {
if err := validateObservationRecords(records); err != nil {
return Report{}, err
}
if len(records) != len(trace) {
return Report{}, fmt.Errorf("cachebench: observation population %d does not match trace population %d", len(records), len(trace))
}
byID := make(map[string]TraceRecord, len(trace))
for index, request := range trace {
if request.Schema != TraceSchema && request.Schema != TraceSchemaV2 || strings.TrimSpace(request.RequestID) == "" {
return Report{}, fmt.Errorf("cachebench: trace request %d has invalid schema or request_id", index)
}
if _, exists := byID[request.RequestID]; exists {
return Report{}, fmt.Errorf("cachebench: duplicate trace request %q", request.RequestID)
}
if strings.TrimSpace(request.Provider) == "" || strings.TrimSpace(request.Epoch) == "" || !validUniqueJSONObject(request.Body) || request.BodySHA256 == "" || request.BodySHA256 != bodyDigest(request.Body) {
return Report{}, fmt.Errorf("cachebench: trace request %q has invalid identity, body, or digest", request.RequestID)
}
if request.StableSegmentCount < 0 || request.StableSegmentCount > len(request.Prefix) || !validPrefix(request.Prefix) {
return Report{}, fmt.Errorf("cachebench: trace request %q has invalid prefix", request.RequestID)
}
byID[request.RequestID] = request
}
for _, record := range records {
request, exists := byID[record.RequestID]
if !exists {
return Report{}, fmt.Errorf("cachebench: observation request %q absent from trace", record.RequestID)
}
if record.Provider != request.Provider || record.Epoch != request.Epoch {
return Report{}, fmt.Errorf("cachebench: observation request %q provider/epoch mismatch", record.RequestID)
}
if record.RequestBodySHA256 == "" || record.RequestBodySHA256 != request.BodySHA256 {
return Report{}, fmt.Errorf("cachebench: observation request %q body digest mismatch", record.RequestID)
}
}View on GitHub (pinned to 27d5a3981a)
Solutions
- Recompute and store bodyDigest(body) whenever the body field is written or modified.
- Keep body as a compact, canonical JSON object; avoid pretty-printing or key reordering after generation.
- Fill in provider and epoch on every trace record.
- Regenerate the trace from the replay rather than transforming it externally.
Defensive patterns
Strategy: validation
Validate before calling
func validTraceRecord(r TraceRecord) error {
if strings.TrimSpace(r.Provider) == "" || strings.TrimSpace(r.Epoch) == "" {
return fmt.Errorf("request %q missing provider/epoch", r.RequestID)
}
if !validUniqueJSONObject(r.Body) {
return fmt.Errorf("request %q body not a unique JSON object", r.RequestID)
}
if r.BodySHA256 != bodyDigest(r.Body) {
return fmt.Errorf("request %q digest stale; recompute", r.RequestID)
}
return nil
} Prevention
- Compute BodySHA256 with bodyDigest at write time and never reformat the body afterwards.
- Treat body bytes as opaque; pass them through unchanged between stages.
- Add a CI check that recomputes digests over fixture traces.
When it happens
Trigger: EvaluateObservedAgainstTrace validating a trace record whose provider/epoch fields are whitespace, whose body is an array or contains duplicate JSON keys, or whose recorded BodySHA256 does not match a fresh SHA-256 of the body bytes.
Common situations: Re-serializing trace JSON through a tool that reformats the body field (breaking the digest); editing body content by hand after generation; body stored as a JSON array instead of an object.
Related errors
- cachebench: observation request %q body digest mismatch
- message %d: %w
- cachebench: observation population %d does not match trace p
- cachebench: trace request %d has invalid schema or request_i
- cachebench: duplicate trace request %q
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/0a6e530755a19f0d.
Report an issue: GitHub.