{"record":{"id":"7b51a84ebca74921","repo":"grafana/k6","slug":"start-local-execution-w","errorCode":null,"errorMessage":"start local execution: %w","messagePattern":"start local execution: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/provision.go","lineNumber":87,"sourceCode":"\tif params.Archive != nil {\n\t\tvar buf bytes.Buffer\n\t\tif err := params.Archive.Write(&buf); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serialising archive: %w\", err)\n\t\t}\n\t\tarchiveSize = int64(buf.Len())\n\t\tarchiveBytes = buf.Bytes()\n\t}\n\n\tsleReq := StartLocalExecutionRequest{\n\t\tOptions:       params.Options,\n\t\tMaxVUs:        params.MaxVUs,\n\t\tTotalDuration: params.TotalDuration,\n\t\tArchiveSize:   archiveSize,\n\t}\n\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{","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/provisioning/provision.go#L69-L105","documentation":"The StartLocalExecution call inside ProvisionLocalExecution failed — the request to begin a cloud-managed local-execution run (carrying Options, MaxVUs, TotalDuration, ArchiveSize) was rejected or did not complete. The wrapped error distinguishes HTTP rejection (ResponseError with status/body) from transport failure (network error).","triggerScenarios":"400 validation when MaxVUs or TotalDuration contradict the marshalled options, quota/plan limits exceeded (402/429), another run of the same test still active (409), invalid token (401), or network failure reaching the provisioning endpoint.","commonSituations":"Sizing parameters computed from a script whose scenarios changed between builds, free-tier limits on VUs or duration, a leftover running test from a crashed previous session, or a stale login configuration.","solutions":["Check the wrapped error's HTTP status and body — fix the reported field (options vs MaxVUs vs duration)","Stop any still-running previous run of the same test in the Grafana Cloud UI or via `k6 cloud` commands, then retry","Verify quota/plan limits for concurrent runs, max VUs, and duration in your Grafana Cloud project","Re-authenticate with `k6 cloud login` if the status is 401/403"],"exampleFix":"// before\nmaxVUs := int64(1000) // hand-typed, may contradict script options\nsleResp, err := client.StartLocalExecution(ctx, loadTestID, provisioning.StartLocalExecutionRequest{MaxVUs: maxVUs, ...})\n\n// after\nmaxVUs := int64(et.GetMaxPossibleVUs()) // derived from the same execution plan\nsleResp, err := client.StartLocalExecution(ctx, loadTestID, provisioning.StartLocalExecutionRequest{MaxVUs: maxVUs, ...})","handlingStrategy":"try-catch","validationCode":"// keep sizing consistent with the execution plan before calling\net, err := lib.NewExecutionTuple(seg, seq)\nif err != nil { return err }\nplan := cfg.Scenarios.GetFullExecutionRequirements(et)\nmaxVUs := int64(plan.GetMaxPossibleVUs())\ntotal := int64(plan.GetDuration() / time.Second)","typeGuard":null,"tryCatchPattern":"sleResp, err := c.StartLocalExecution(ctx, loadTestID, sleReq)\nif err != nil {\n    var respErr *cloudapiv6.ResponseError\n    if errors.As(err, &respErr) {\n        switch respErr.Response.StatusCode {\n        case 409: return nil, fmt.Errorf(\"previous run still active: %w\", err)\n        case 402, 429: return nil, fmt.Errorf(\"quota exceeded: %w\", err)\n        }\n    }\n    return nil, fmt.Errorf(\"start local execution: %w\", err)\n}","preventionTips":["Derive MaxVUs/TotalDuration from the same execution plan you send as Options","Stop previous runs of the same test before starting a new one (scripted `k6 cloud stop`)","Surface 402/429 distinctly so operators know it is quota, not a bug"],"tags":["cloud-api","provisioning","validation","quota"],"backgroundTag":"api-request-failed","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"}