{"record":{"id":"41bd2f47d17dbd09","repo":"grafana/k6","slug":"uploading-test-w","errorCode":null,"errorMessage":"uploading test: %w","messagePattern":"uploading test: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/cloud.go","lineNumber":254,"sourceCode":"\tlogger := c.gs.Logger\n\n\t// Start cloud test run\n\tmodifyAndPrintBar(c.gs, progressBar, pb.WithConstProgress(0, \"Validating script options\"))\n\tclient, err := cloudapiv6.NewClient(\n\t\tlogger, cloudConfig.Token.String, cloudConfig.Hostv6.String, build.Version, cloudConfig.Timeout.TimeDuration())\n\tif err != nil {\n\t\treturn err\n\t}\n\tprojectID, err := prepCloudTestRun(globalCtx, c.gs, client, &cloudConfig, tmpCloudConfig, arc)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmodifyAndPrintBar(c.gs, progressBar, pb.WithConstProgress(0, \"Uploading archive\"))\n\n\tloadTest, err := client.UploadTest(globalCtx, name, projectID, arc)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"uploading test: %w\", err)\n\t}\n\n\tif c.uploadOnly {\n\t\tet, err := lib.NewExecutionTuple(test.derivedConfig.ExecutionSegment, test.derivedConfig.ExecutionSegmentSequence)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\texecutionPlan := test.derivedConfig.Scenarios.GetFullExecutionRequirements(et)\n\t\ttestURL, err := resolveCloudTestURL(cloudConfig.StackURL.String, loadTest.GetId())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tprintExecutionDescription(\n\t\t\tc.gs, \"cloud\", test.sourceRootPath, testURL, test.derivedConfig, et, executionPlan, nil,\n\t\t)\n\t\tmodifyAndPrintBar(c.gs, progressBar, pb.WithConstLeft(\"Run \"), pb.WithConstProgress(1.0, \"Archived\"))\n\t\tc.printTestStatus(\"Archived\")\n\t\treturn nil","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/cloud.go#L236-L272","documentation":"The `k6 cloud` run path wraps any failure of client.UploadTest in this error. UploadTest POSTs the bundled script archive to the cloud API, so the wrapped error can be a structured ResponseError (auth failure, invalid project), an HTTP/network error (timeout, connection reset), or a body-size rejection. The '%w' keeps the underlying cause attached for inspection.","triggerScenarios":"Calling k6 cloud (or the API path UploadTest) when the server rejects the archive upload: 401/403 bad token, 404 wrong project ID, 413 archive too large, request timeout per K6_CLOUD_TIMEOUT, or a network failure between the runner and the API host.","commonSituations":"Scripts that bundle large assets (node_modules, binaries, big JSON fixtures) exceeding upload limits; expired or revoked API tokens; wrong --project-id; restrictive egress firewalls in CI; slow links hitting the default request timeout.","solutions":["Read the wrapped error text after the colon: ResponseError messages name the exact server reason","Shrink the archive: remove unused files, use module CDNs, avoid bundling large fixtures","Verify token validity and --project-id / K6_CLOUD_PROJECT_ID","Increase K6_CLOUD_TIMEOUT if the upload times out on slow links","Retry: transient 5xx and connection resets are common for large uploads"],"exampleFix":"# before\nk6 cloud script.js  # archive includes ./data/10GB.json\n# after\necho 'data/*.json' > .gitignore  # or move fixtures out and load at runtime\nk6 cloud script.js","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var re cloudapiv6.ResponseError\nif errors.As(err, &re) {\n    switch re.Response.StatusCode {\n    case 401, 403: // permanent: fix token, do not retry\n    case 413: // permanent: shrink archive\n    default: // retry with backoff up to N times\n    }\n}","preventionTips":["Keep archives small: exclude fixtures and node_modules from the bundle","Set K6_CLOUD_TIMEOUT generously for large uploads on slow links","Validate token and project ID in a pre-flight step (e.g. `k6 cloud test list`) before uploading"],"tags":["cloud-api","upload","network","archive"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}