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

  1. Capture the raw response body (temporarily swap in a debugging transport) and inspect it
  2. Verify the push/notify URL comes from provisioning runtime_config unmodified
  3. Check proxy and TLS-interception settings for the host
  4. 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

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


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/7e630998ae13b2c7. Report an issue: GitHub.