{"record":{"id":"ff0f61c15847a04e","repo":"grafana/k6","slug":"failed-to-read-response-body-w","errorCode":null,"errorMessage":"failed to read response body: %w","messagePattern":"failed to read response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/secretsource/url/url.go","lineNumber":241,"sourceCode":"func newLimiter(requestsPerMinuteLimit, requestsBurst int) *rate.Limiter {\n\t// The calculation below looks wrong because it seems like it's giving\n\t// n min²/req, but the first number is actually time unit/min, so the\n\t// units of the result are time unit/req, which is correct because it's\n\t// the interval of time after which a new token is replenished. In\n\t// other words, the units are time unit/token.\n\ttokenReplenishInterval := time.Minute / time.Duration(requestsPerMinuteLimit)\n\n\treturn rate.NewLimiter(rate.Every(tokenReplenishInterval), requestsBurst)\n}\n\nfunc extractSecretFromResponse(body io.Reader, responsePath string) (string, error) {\n\tconst maxSecretSize = 24 * 1024\n\n\t// Limit reading to prevent memory exhaustion from large responses\n\tlimitedReader := io.LimitReader(body, maxSecretSize+1)\n\tdata, err := io.ReadAll(limitedReader)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read response body: %w\", err)\n\t}\n\n\tif len(data) > maxSecretSize {\n\t\treturn \"\", fmt.Errorf(\"secret response exceeds maximum size of %d bytes\", maxSecretSize)\n\t}\n\n\tif responsePath == \"\" {\n\t\t// If no path specified, assume response body is the secret\n\t\treturn string(data), nil\n\t}\n\n\tresult := gjson.GetBytes(data, responsePath)\n\n\tif !result.Exists() {\n\t\treturn \"\", fmt.Errorf(\"path %q not found in response\", responsePath)\n\t}\n\n\tif result.Type != gjson.String {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/secretsource/url/url.go#L223-L259","documentation":"extractSecretFromResponse reads the HTTP response through an io.LimitReader capped at 24 KiB (maxSecretSize) to bound memory use; io.ReadAll failed here (e.g. connection reset mid-body or read timeout). The secret cannot be extracted and Get fails.","triggerScenarios":"Thrown at internal/secretsource/url/url.go:241 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the secret fetch; mid-body read failures are typically transient network issues","Check service stability and network connectivity to the secret endpoint"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}