grafana/k6 · warning
decoding response: %w
Error message
decoding response: %w
What it means
HTTPClient.Do (internal/cloudapi/provisioning/http_client.go:73) decodes a 2xx response body into the caller's JSON target; an empty body is tolerated (io.EOF), but any other decode failure returns this error. It means the server returned success with a body that is not the expected JSON — a rewritten/proxied response, an HTML error page, or a truncated stream.
Source
Thrown at internal/cloudapi/provisioning/http_client.go:73
req.Header.Set("User-Agent", "k6cloud/"+p.version)
resp, err := doWithRetry(p.httpClient, req)
if err != nil {
return err
}
defer func() {
_, _ = io.Copy(io.Discard, resp.Body)
_ = resp.Body.Close()
}()
if err := CheckResponse(resp); err != nil {
return err
}
if v != nil {
if err := json.NewDecoder(resp.Body).Decode(v); err != nil && !errors.Is(err, io.EOF) {
return fmt.Errorf("decoding response: %w", err)
}
}
return nil
}
View on GitHub (pinned to 93accf6570)
Solutions
- Capture the raw response body (temporarily swap in a debugging transport) and inspect it
- Verify the push/notify URL comes from provisioning runtime_config unmodified
- Check proxy and TLS-interception settings for the host
- Compare the k6 version with the cloud API version; update k6 if the schema drifted
Defensive patterns
Strategy: try-catch
Type guard
func isJSONDecodeFailure(err error) bool {
var syn *json.SyntaxError
var un *json.UnmarshalTypeError
return errors.As(err, &syn) || errors.As(err, &un)
} Try / catch
if err := httpClient.Do(req, &out); err != nil {
if isJSONDecodeFailure(err) {
// 2xx but non-JSON body: suspect proxy/URL drift, capture and inspect the body
log.Printf("response was not JSON: %v", err)
}
return err
} Prevention
- Verify push/notify URLs come from provisioning runtime_config unmodified
- Bypass or pin TLS-intercepting proxies for cloud API hosts
- Capture raw bodies in a debug mode to diagnose decode failures quickly
When it happens
Trigger: Corporate proxy or MITM rewriting the metrics-push/notify response; push URL pointing at a non-API endpoint; connection reset truncating the body mid-transfer; backend version returning a different schema shape.
Common situations: HTTPS_PROXY environments injecting interstitial pages; misconfigured push URL from runtime_config; transient truncation on flaky links; k6/backend schema drift after upgrades.
Related errors
- unexpected HTTP error from %s: %d %s
- unexpected HTTP error from %s: %d %s
- unmarshalling response body to JSON: %w
- HTTP exporter endpoint is required
- cookie: is null
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/7e630998ae13b2c7.
Report an issue: GitHub.