{"record":{"id":"7e630998ae13b2c7","repo":"grafana/k6","slug":"decoding-response-w","errorCode":null,"errorMessage":"decoding response: %w","messagePattern":"decoding response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/cloudapi/provisioning/http_client.go","lineNumber":73,"sourceCode":"\treq.Header.Set(\"User-Agent\", \"k6cloud/\"+p.version)\n\n\tresp, err := doWithRetry(p.httpClient, req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer func() {\n\t\t_, _ = io.Copy(io.Discard, resp.Body)\n\t\t_ = resp.Body.Close()\n\t}()\n\n\tif err := CheckResponse(resp); err != nil {\n\t\treturn err\n\t}\n\n\tif v != nil {\n\t\tif err := json.NewDecoder(resp.Body).Decode(v); err != nil && !errors.Is(err, io.EOF) {\n\t\t\treturn fmt.Errorf(\"decoding response: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":55,"sourceCodeEnd":79,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/http_client.go#L55-L79","documentation":"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.","triggerScenarios":"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.","commonSituations":"HTTPS_PROXY environments injecting interstitial pages; misconfigured push URL from runtime_config; transient truncation on flaky links; k6/backend schema drift after upgrades.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isJSONDecodeFailure(err error) bool {\n\tvar syn *json.SyntaxError\n\tvar un *json.UnmarshalTypeError\n\treturn errors.As(err, &syn) || errors.As(err, &un)\n}","tryCatchPattern":"if err := httpClient.Do(req, &out); err != nil {\n\tif isJSONDecodeFailure(err) {\n\t\t// 2xx but non-JSON body: suspect proxy/URL drift, capture and inspect the body\n\t\tlog.Printf(\"response was not JSON: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["json","decoding","http","proxy","schema-drift"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}