JuliusBrussee/caveman · error
cachebench: request needs or for reconstruction
Error message
cachebench: request %q needs %s or %s for reconstruction
What it means
Raised by TraceRecord.NativeRequest: reconstructing the exact optimizer input (native provider request) requires a v2 or v3 trace, because legacy v1 traces omitted routing and economics inputs. The %q request id names the record whose schema is too old; v1 records remain readable for observation joins but cannot drive live replay.
Solutions
- Re-capture the trace with a v2/v3-schema writer so routing and economics inputs are recorded
- Skip replay for v1 records and use them only for observation joins
- Convert the v1 trace upstream by re-issuing the captured requests through a current writer
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at cacheengine/cachebench/trace.go:352 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/6440c8b95293eca2.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/trace.go:352
seen[record.RequestID] = true
record.Body = append(json.RawMessage(nil), record.Body...)
records = append(records, record)
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("cachebench: read trace: %w", err)
}
if len(records) == 0 {
return nil, errors.New("cachebench: no trace records")
}
return records, nil
}
// NativeRequest reconstructs exact optimizer input captured by v2 or v3 trace.
// Legacy v1 traces remain readable for observation joins, but cannot drive live
// replay because they omitted routing and economics inputs.
func (record TraceRecord) NativeRequest() (cacheengine.NativeRequest, error) {
if record.Schema != TraceSchema && record.Schema != TraceSchemaV2 {
return cacheengine.NativeRequest{}, fmt.Errorf("cachebench: request %q needs %s or %s for reconstruction", record.RequestID, TraceSchemaV2, TraceSchema)
}
if !validTraceIdentity(record) || !validTimingBasis(record.TimingBasis) || record.ExpectedRPM <= 0 || record.ExpectedCalls <= 0 || record.PrefixTokens < 0 || !validUniqueJSONObject(record.Body) || record.BodySHA256 != bodyDigest(record.Body) || record.StableSegmentCount < 0 || record.StableSegmentCount > len(record.Prefix) || !validPrefix(record.Prefix) {
return cacheengine.NativeRequest{}, fmt.Errorf("cachebench: request %q has incomplete or invalid replay identity", record.RequestID)
}
return cacheengine.NativeRequest{
Scope: record.Scope, Epoch: record.Epoch, PartitionKey: record.PartitionKey,
ExpectedRequestsPerMinute: record.ExpectedRPM, ExpectedCalls: record.ExpectedCalls,
Provider: record.Provider, Model: record.Model, Region: record.Region, Endpoint: record.Endpoint,
Body: append([]byte(nil), record.Body...), RuntimeMode: record.RuntimeMode, AuthMode: record.AuthMode,
PrefixTokens: record.PrefixTokens,
}, nil
}
func validTraceIdentity(record TraceRecord) bool {
return validBoundedText(record.RequestID, 512, false) &&
validBoundedText(record.Provider, 64, false) &&
validBoundedText(record.Model, 512, false) &&
validBoundedText(record.Region, 64, true) &&View on GitHub (pinned to 766dce6b13)