{"record":{"id":"1a6dad69c1eb8cfd","repo":"grafana/k6","slug":"creating-new-request-w","errorCode":null,"errorMessage":"creating new request: %w","messagePattern":"creating new request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/storage/file_persister.go","lineNumber":239,"sourceCode":"\tff, err := fw.CreateFormFile(\"file\", psu.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating multipart form file: %w\", err)\n\t}\n\tif _, err := io.Copy(ff, data); err != nil {\n\t\treturn nil, fmt.Errorf(\"copying file data to multipart form: %w\", err)\n\t}\n\tif err := fw.Close(); err != nil {\n\t\treturn nil, fmt.Errorf(\"closing multipart form writer: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(\n\t\tctx,\n\t\tpsu.Method,\n\t\tpsu.PresignedURL,\n\t\t&form,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating new request: %w\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", fw.FormDataContentType())\n\n\treturn req, nil\n}\n\nfunc checkStatusCode(resp *http.Response) error {\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {\n\t\treturn fmt.Errorf(\"server returned %d (%s)\", resp.StatusCode, strings.ToLower(http.StatusText(resp.StatusCode)))\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":221,"sourceCodeEnd":253,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/storage/file_persister.go#L221-L253","documentation":"Raised in newFileUploadRequest when http.NewRequestWithContext fails to build the upload request from the presigned response — method '%s' from psu.Method, URL from psu.PresignedURL, body the assembled multipart form. It fires when the service-supplied presigned URL is not parseable or the method is invalid (net/http validates both), or the context is already canceled. The inputs at fault come from the remote presigned-URL response.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/storage/file_persister.go:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the persist for a fresh presigned URL","Report to k6 Cloud support if the returned presigned URL or method is consistently invalid","Verify the execution context is not canceled prematurely"],"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"}