{"record":{"id":"7407bbeb71340659","repo":"JuliusBrussee/caveman","slug":"cachebench-nil-http-replay-transport","errorCode":null,"errorMessage":"cachebench: nil HTTP replay transport","messagePattern":"cachebench: nil HTTP replay transport","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay_http.go","lineNumber":121,"sourceCode":"\t\t\t\tResponseHeaderTimeout: 90 * time.Second,\n\t\t\t\tIdleConnTimeout:       90 * time.Second,\n\t\t\t},\n\t\t}\n\t} else {\n\t\tclone := *client\n\t\tif config.RequestTimeout != 0 || clone.Timeout <= 0 || clone.Timeout > requestTimeout {\n\t\t\tclone.Timeout = requestTimeout\n\t\t}\n\t\tclient = &clone\n\t}\n\tclient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error { return http.ErrUseLastResponse }\n\treturn &HTTPReplayTransport{client: client, credentials: config.Credentials, baseURLs: parsed, maxRequestBytes: requestLimit, maxResponseBytes: limit}, nil\n}\n\n// Send authenticates and sends one bounded provider request without retry.\nfunc (transport *HTTPReplayTransport) Send(ctx context.Context, outbound ReplayOutbound) (ReplayResponse, error) {\n\tif transport == nil || transport.client == nil {\n\t\treturn ReplayResponse{}, errors.New(\"cachebench: nil HTTP replay transport\")\n\t}\n\tif int64(len(outbound.Body)) > transport.maxRequestBytes {\n\t\treturn ReplayResponse{}, errors.New(\"cachebench: replay body exceeds configured request limit\")\n\t}\n\tprovider := strings.ToLower(strings.TrimSpace(outbound.Provider))\n\tif !validBoundedText(provider, 64, false) {\n\t\treturn ReplayResponse{}, errors.New(\"cachebench: invalid replay provider\")\n\t}\n\tendpoint, err := transport.endpoint(provider, outbound)\n\tif err != nil {\n\t\treturn ReplayResponse{}, err\n\t}\n\tif !validUniqueJSONObject(outbound.Body) {\n\t\treturn ReplayResponse{}, errors.New(\"cachebench: replay body must be one JSON object\")\n\t}\n\trequest, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), bytes.NewReader(outbound.Body))\n\tif err != nil {\n\t\treturn ReplayResponse{}, errors.New(\"cachebench: could not build provider request\")","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay_http.go#L103-L139","documentation":"Sentinel guard at the top of HTTPReplayTransport.Send: the method was invoked on a nil transport or on a transport constructed without an http.Client. This never happens via NewHTTPReplayTransport; it indicates the transport struct was built zero-valued or manually, breaking the constructor's invariant that a client (with timeouts and CheckRedirect) always exists.","triggerScenarios":"Thrown at cacheengine/cachebench/replay_http.go:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Construct the transport via NewHTTPReplayTransport instead of a zero-value struct","Check initialization order so Send is not called before construction"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}