{"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":"critical","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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/provision.go#L69-L105","documentation":"Client.ProvisionLocalExecution (internal/cloudapi/provisioning/provision.go:87) wraps the failure of Client.StartLocalExecution — the POST start_local_execution call. This is an umbrella error: it can be any of the request-building failures (idempotency key, options JSON, int32 conversions) or, most commonly, a non-2xx from CheckResponse (401/403 auth, 404 unknown load test, 409/422 rejected request, 5xx) or a transport error.","triggerScenarios":"loadTestID returned by CreateOrFindLoadTest is not startable; backend rejects the submitted options or archive size; token lacks execution permission; org quota/plan limits hit; cloud API version incompatible with this k6 build.","commonSituations":"Free-tier or quota exhaustion; schema drift after a cloud API release versus an older k6; tokens with read-only scopes; archive/options mismatches after script changes.","solutions":["Unwrap and read the exact status/body: auth vs not-found vs validation vs quota each have different fixes","Verify the load test exists and the token can execute tests in that project","Check org quotas and plan limits in Grafana Cloud","Upgrade (or pin) k6 to a version aligned with the current cloud API if 400/422 schema errors appear","Re-run once to rule out transient 5xx (the K6-Idempotency-Key makes retries safe)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if loadTestID <= 0 {\n\treturn errors.New(\"invalid load test ID; cannot start local execution\")\n}\nif !json.Valid(params.Options) {\n\treturn errors.New(\"options JSON invalid; refusing to start local execution\")\n}","typeGuard":"func isProvisioningHTTPError(err error) (int, bool) {\n\tvar re *provisioning.ResponseError\n\tif errors.As(err, &re) {\n\t\treturn re.StatusCode, true\n\t}\n\treturn 0, false\n}","tryCatchPattern":"res, err := client.ProvisionLocalExecution(ctx, params)\nif err != nil {\n\tif code, ok := isProvisioningHTTPError(err); ok {\n\t\tswitch {\n\t\tcase code == 401 || code == 403:\n\t\t\t// token scope problem\n\t\tcase code == 404:\n\t\t\t// load test / endpoint mismatch\n\t\tcase code >= 500:\n\t\t\t// safe to retry: request carried an idempotency key\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Pre-validate options JSON and numeric fields before provisioning","Keep k6 updated in lockstep with cloud API releases","Rely on the K6-Idempotency-Key and retry 5xxs instead of abandoning runs","Inspect status+body before changing configuration — the umbrella message alone is ambiguous"],"tags":["cloud-api","provisioning","http","startup","quota"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}