JuliusBrussee/caveman · error
cachebench: replay body must be one JSON object
Error message
cachebench: replay body must be one JSON object
What it means
Send requires the replay body to be exactly one JSON object and validates it with validUniqueJSONObject before building the provider request. The error fires when outbound.Body is not a single JSON object (array, scalar, fragment, multiple concatenated values) or when duplicate keys make the payload ambiguous for cache replay.
Solutions
- Ensure the recorded request body is a single valid JSON object
- Re-capture the replay body if it was truncated or concatenated
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/replay_http.go:135 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/2ec8a6a07555e632.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/replay_http.go:135
// Send authenticates and sends one bounded provider request without retry.
func (transport *HTTPReplayTransport) Send(ctx context.Context, outbound ReplayOutbound) (ReplayResponse, error) {
if transport == nil || transport.client == nil {
return ReplayResponse{}, errors.New("cachebench: nil HTTP replay transport")
}
if int64(len(outbound.Body)) > transport.maxRequestBytes {
return ReplayResponse{}, errors.New("cachebench: replay body exceeds configured request limit")
}
provider := strings.ToLower(strings.TrimSpace(outbound.Provider))
if !validBoundedText(provider, 64, false) {
return ReplayResponse{}, errors.New("cachebench: invalid replay provider")
}
endpoint, err := transport.endpoint(provider, outbound)
if err != nil {
return ReplayResponse{}, err
}
if !validUniqueJSONObject(outbound.Body) {
return ReplayResponse{}, errors.New("cachebench: replay body must be one JSON object")
}
request, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), bytes.NewReader(outbound.Body))
if err != nil {
return ReplayResponse{}, errors.New("cachebench: could not build provider request")
}
request.Header.Set("content-type", "application/json")
request.Header.Set("accept", "application/json")
request.Header.Set("user-agent", "caveman-cachebench-replay/1")
if err := transport.authorize(provider, outbound.Region, request, outbound.Body); err != nil {
return ReplayResponse{}, err
}
response, err := transport.client.Do(request)
if err != nil {
return ReplayResponse{}, errors.New("cachebench: provider request failed")
}
defer response.Body.Close()
body, err := io.ReadAll(io.LimitReader(response.Body, transport.maxResponseBytes+1))
if err != nil {View on GitHub (pinned to 766dce6b13)