JuliusBrussee/caveman · error
cachebench: optimize request
Error message
cachebench: optimize request %q: %w
What it means
Engine wrap in ReplayRunner.prepare: runner.Engine.Optimize failed for the named request while computing its optimized form. The wrapped error is the engine failure; the request's native body may be unsupported.
Solutions
- Inspect the wrapped engine error (often malformed request bodies or unsupported providers)
- Fix the cited trace record and re-run preparation
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/replay.go:513 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/3577497b13bb14d2.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/replay.go:513
type preparedReplay struct {
record TraceRecord
optimized cacheengine.NativeResult
}
func (runner ReplayRunner) prepare(ctx context.Context, records []TraceRecord) ([]preparedReplay, error) {
prepared := make([]preparedReplay, 0, len(records))
for _, record := range records {
if err := ctx.Err(); err != nil {
return nil, fmt.Errorf("cachebench: replay preparation interrupted: %w", err)
}
native, err := record.NativeRequest()
if err != nil {
return nil, err
}
optimized, err := runner.Engine.Optimize(ctx, native)
if err != nil {
return nil, fmt.Errorf("cachebench: optimize request %q: %w", record.RequestID, err)
}
equivalent := bytes.Equal(native.Body, optimized.Body)
if optimized.Applied {
equivalent = ModelVisibleEquivalent(native.Body, optimized.Body)
}
if !equivalent {
return nil, &ReplayRunError{
RequestID: record.RequestID, FailureCode: "model_visible_mismatch",
Err: fmt.Errorf("cachebench: request %q failed model-visible equivalence", record.RequestID),
}
}
if optimized.Decision != cacheengine.DecisionApply && optimized.Decision != cacheengine.DecisionObserveOnly && optimized.Reason != cacheengine.ReasonBelowMinimum {
return nil, &ReplayRunError{
RequestID: record.RequestID, FailureCode: "engine_not_cacheable",
Err: fmt.Errorf("cachebench: request %q is not cacheable: %s", record.RequestID, optimized.Reason),
}
}
prepared = append(prepared, preparedReplay{record: record, optimized: optimized})View on GitHub (pinned to 766dce6b13)