{"record":{"id":"19b550f3191a2666","repo":"grafana/k6","slug":"building-request-body-w","errorCode":null,"errorMessage":"building request body: %w","messagePattern":"building request body: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/storage/file_persister.go","lineNumber":128,"sourceCode":"\tdefer resp.Body.Close() //nolint:errcheck\n\n\tif _, err := io.Copy(io.Discard, resp.Body); err != nil {\n\t\treturn fmt.Errorf(\"draining upload response body: %w\", err)\n\t}\n\n\tif err := checkStatusCode(resp); err != nil {\n\t\treturn fmt.Errorf(\"uploading: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// requestPresignedURL will request a new presigned URL from the remote server\n// and returns a [PresignedURLResponse] that contains the presigned URL details.\nfunc (r *RemoteFilePersister) requestPresignedURL(ctx context.Context, path string) (PresignedURLResponse, error) {\n\tb, err := buildPresignedRequestBody(r.basePath, path)\n\tif err != nil {\n\t\treturn PresignedURLResponse{}, fmt.Errorf(\"building request body: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(\n\t\tctx,\n\t\thttp.MethodPost,\n\t\tr.presignedURLRequestURL,\n\t\tbytes.NewReader(b),\n\t)\n\tif err != nil {\n\t\treturn PresignedURLResponse{}, fmt.Errorf(\"creating request: %w\", err)\n\t}\n\n\tfor k, v := range r.headers {\n\t\treq.Header.Add(k, v)\n\t}\n\n\tresp, err := r.httpClient.Do(req) //nolint:gosec\n\tif err != nil {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/storage/file_persister.go#L110-L146","documentation":"Raised in requestPresignedURL when buildPresignedRequestBody fails to construct the JSON payload describing the file to upload (service, operation, file name joined from basePath and path). The only realistic failure inside that helper is json.Marshal of the request struct, so this fires on serialization of an invalid value — effectively an internal invariant break, since the struct fields are plain strings.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/storage/file_persister.go:128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as an internal error: report a k6 bug with the artifact path that triggered it","Update k6 to a newer version in case the payload builder was fixed","Verify the basePath/path configuration values are sane strings"],"exampleFix":null,"handlingStrategy":"fallback","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-14T00:17:10.932Z"}