grafana/k6 · error
failed to read response body: %w
Error message
failed to read response body: %w
What it means
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.
Source
Thrown at internal/secretsource/url/url.go:241
func newLimiter(requestsPerMinuteLimit, requestsBurst int) *rate.Limiter {
// The calculation below looks wrong because it seems like it's giving
// n min²/req, but the first number is actually time unit/min, so the
// units of the result are time unit/req, which is correct because it's
// the interval of time after which a new token is replenished. In
// other words, the units are time unit/token.
tokenReplenishInterval := time.Minute / time.Duration(requestsPerMinuteLimit)
return rate.NewLimiter(rate.Every(tokenReplenishInterval), requestsBurst)
}
func extractSecretFromResponse(body io.Reader, responsePath string) (string, error) {
const maxSecretSize = 24 * 1024
// Limit reading to prevent memory exhaustion from large responses
limitedReader := io.LimitReader(body, maxSecretSize+1)
data, err := io.ReadAll(limitedReader)
if err != nil {
return "", fmt.Errorf("failed to read response body: %w", err)
}
if len(data) > maxSecretSize {
return "", fmt.Errorf("secret response exceeds maximum size of %d bytes", maxSecretSize)
}
if responsePath == "" {
// If no path specified, assume response body is the secret
return string(data), nil
}
result := gjson.GetBytes(data, responsePath)
if !result.Exists() {
return "", fmt.Errorf("path %q not found in response", responsePath)
}
if result.Type != gjson.String {View on GitHub (pinned to 01ffac6f24)
Solutions
- Retry the secret fetch; mid-body read failures are typically transient network issues
- Check service stability and network connectivity to the secret endpoint
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/secretsource/url/url.go:241 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/ff0f61c15847a04e.
Report an issue: GitHub.