{"record":{"id":"b5919b3ef512a4ac","repo":"grafana/k6","slug":"wait-for-test-run-ready-w","errorCode":null,"errorMessage":"wait for test run ready: %w","messagePattern":"wait for test run ready: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/provision.go","lineNumber":102,"sourceCode":"\n\tsleResp, err := c.StartLocalExecution(ctx, loadTestID, sleReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"start local execution: %w\", err)\n\t}\n\n\tswitch {\n\tcase params.Archive != nil && sleResp.ArchiveUploadURL != nil:\n\t\tif err := c.UploadArchive(ctx, *sleResp.ArchiveUploadURL, archiveBytes); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"upload archive: %w\", err)\n\t\t}\n\tcase params.Archive != nil && sleResp.ArchiveUploadURL == nil:\n\t\t// We had an archive to upload but the API returned no upload URL;\n\t\t// proceed without uploading rather than failing the run.\n\t\tc.logger.Warn(\"archive present but provisioning API returned no upload URL; skipping archive upload\")\n\t}\n\n\tif err := c.WaitForTestRunReady(ctx, sleResp.TestRunID, params.PollInterval); err != nil {\n\t\treturn nil, fmt.Errorf(\"wait for test run ready: %w\", err)\n\t}\n\n\treturn &ProvisionResult{\n\t\tTestRunID:             sleResp.TestRunID,\n\t\tTestRunDetailsPageURL: sleResp.TestRunDetailsPageURL,\n\t\tRuntimeConfig:         sleResp.RuntimeConfig,\n\t}, nil\n}\n","sourceCodeStart":84,"sourceCodeEnd":111,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/provisioning/provision.go#L84-L111","documentation":"The final provisioning step failed: WaitForTestRunReady did not observe the cloud test run reach a ready/running state. This polls the test-run status and fails when the run transitions to an errored/invalid terminal state, when polling exceeds its time budget, or when the context is canceled — so the cloud side rejected or stalled the run after it was created.","triggerScenarios":"Cloud-side validation rejects the uploaded options or archive and marks the run errored; the run stays in a transitional state past the polling deadline; ctx canceled by user signal; or repeated 5xx while polling.","commonSituations":"Script options the backend refuses (unsupported scenarios or thresholds combinations), an archive that failed server-side processing, a long queue on the cloud service during peak times, or CI environments with tight outer timeouts killing the wait.","solutions":["Open the test run details page (TestRunDetailsPageURL was not returned, so find the run by testRunID in the Grafana Cloud UI) and read the cloud-side error","If the failure is a timeout with the run still transitional, increase the wait budget / PollInterval tolerance and retry provisioning","Re-verify options locally: `k6 inspect script.js` and a dry `k6 run` catch most option-level rejections","If ctx was canceled (Ctrl+C in CI), fix the outer timeout or remove the cancellation"],"exampleFix":"// before\nres, err := client.ProvisionLocalExecution(ctx, params) // default poll interval\n\n// after\nparams.PollInterval = 2 * time.Second // give the backend steadier polling\nctx, cancel := context.WithTimeout(ctx, 10*time.Minute)\ndefer cancel()\nres, err := client.ProvisionLocalExecution(ctx, params)","handlingStrategy":"retry","validationCode":"if params.PollInterval <= 0 {\n    params.PollInterval = 5 * time.Second // explicit, predictable polling\n}\nif _, ok := ctx.Deadline(); !ok {\n    ctx, cancel = context.WithTimeout(ctx, 15*time.Minute)\n}","typeGuard":null,"tryCatchPattern":"if err := c.WaitForTestRunReady(ctx, sleResp.TestRunID, params.PollInterval); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        // run may still be preparing; check state once more before failing\n        return nil, fmt.Errorf(\"wait for test run ready timed out; check run %d in the UI: %w\", sleResp.TestRunID, err)\n    }\n    return nil, fmt.Errorf(\"wait for test run ready: %w\", err)\n}","preventionTips":["Set an explicit outer context deadline sized to worst-case cloud preparation time","Catch option-level rejections early with `k6 inspect` and local dry runs","Log testRunID in every failure path so operators can jump straight to the UI"],"tags":["provisioning","polling","timeout","test-run-state"],"backgroundTag":"polling-timeout","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}