{"record":{"id":"5ad8e1bf0143e6a8","repo":"grafana/k6","slug":"decoding-response-body-w","errorCode":null,"errorMessage":"decoding response body: %w","messagePattern":"decoding response body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/storage/file_persister.go","lineNumber":191,"sourceCode":"\t\t\t},\n\t\t},\n\t}\n\n\tbb, err := json.Marshal(b)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshaling request body: %w\", err)\n\t}\n\n\treturn bb, nil\n}\n\nfunc readPresignedURLResponse(resp *http.Response) (PresignedURLResponse, error) {\n\tvar rb PresignedURLResponse\n\n\tdecoder := json.NewDecoder(resp.Body)\n\terr := decoder.Decode(&rb)\n\tif err != nil {\n\t\treturn PresignedURLResponse{}, fmt.Errorf(\"decoding response body: %w\", err)\n\t}\n\n\tif len(rb.URLs) == 0 {\n\t\treturn PresignedURLResponse{}, errors.New(\"missing presigned url in response body\")\n\t}\n\n\treturn rb, nil\n}\n\n// newFileUploadRequest creates a new HTTP request to upload a file as a multipart\n// form to the presigned URL received from the server.\nfunc newFileUploadRequest(\n\tctx context.Context,\n\tresp PresignedURLResponse,\n\tdata io.Reader,\n) (*http.Request, error) {\n\t// we don't support multiple presigned URLs at the moment.\n\tpsu := resp.URLs[0]","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/storage/file_persister.go#L173-L209","documentation":"Raised in readPresignedURLResponse when json.Decoder.Decode fails while parsing the presigned-URL service response body into PresignedURLResponse. This fires when the remote endpoint returns a body that is not valid JSON or is truncated — e.g. an HTML error page from a proxy, a gateway timeout body, or a connection cut mid-response. Note the distinct sibling check: a valid JSON body with zero URLs produces 'missing presigned url in response body' instead.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/storage/file_persister.go:191 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the presigned-URL endpoint configuration points to the real k6 Cloud API","Check for intermediary proxies returning HTML error pages","Retry the persist; transient gateway/proxy failures are common","Capture the raw response body (debug logging) to identify what non-JSON content was returned"],"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-14T05:17:10.506Z"}