{"record":{"id":"0919c4057fe57a3c","repo":"grafana/k6","slug":"max-vus-w","errorCode":null,"errorMessage":"max_vus: %w","messagePattern":"max_vus: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/api.go","lineNumber":206,"sourceCode":"// safe retries. The caller provides options as pre-marshalled JSON.\nfunc (c *Client) StartLocalExecution(\n\tctx context.Context, loadTestID int64, req StartLocalExecutionRequest,\n) (*StartLocalExecutionResponse, error) {\n\t// Generate idempotency key: 8 random bytes hex-encoded (16 chars).\n\tvar key [8]byte\n\tif _, err := rand.Read(key[:]); err != nil {\n\t\treturn nil, fmt.Errorf(\"generating idempotency key: %w\", err)\n\t}\n\n\t// SDK adapter: unmarshal json.RawMessage → map[string]any.\n\tvar opts map[string]any\n\tif err := json.Unmarshal(req.Options, &opts); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshalling options for SDK: %w\", err)\n\t}\n\n\tmaxVUs, err := toInt32(req.MaxVUs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"max_vus: %w\", err)\n\t}\n\ttotalDuration, err := toInt32(req.TotalDuration)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"total_duration: %w\", err)\n\t}\n\n\tsdkReq := k6cloud.NewStartLocalExecutionTestRequest(opts, maxVUs, totalDuration)\n\n\tif req.ArchiveSize > 0 {\n\t\tv, err := toInt32(req.ArchiveSize)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"archive_size: %w\", err)\n\t\t}\n\t\tsdkReq.SetArchiveSize(v)\n\t} else {\n\t\tsdkReq.SetArchiveSizeNil()\n\t}\n","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/api.go#L188-L224","documentation":"Client.StartLocalExecution (internal/cloudapi/provisioning/api.go:206) converts req.MaxVUs from int64 to int32 via toInt32 because the cloud OpenAPI schema types max_vus as int32. The error means the value lies outside [-2147483648, 2147483647]. No real VU count reaches this range; the value is garbage, misparsed, or overflows from upstream arithmetic.","triggerScenarios":"options.MaxVUs computed from unvalidated input (e.g. an env var parsed with a typo like 99999999999), an integer overflow in caller-side summing of executor VUs, or a negative sentinel leaking into the field beyond int32 range.","commonSituations":"Scripts with absurd vus/max-vus settings; automation multiplying units; a corrupted config value passed through several layers without range checks.","solutions":["Inspect the resolved options (k6 inspect or debug log) and fix the absurd VU count","Clamp or validate MaxVUs against a sane upper bound (cloud plans cap far below 2^31) before provisioning","Find where the value is computed (env var, flag, options merging) and correct the unit/logic","Treat this as a symptom of wrong input, not a cloud-side limit"],"exampleFix":"// before\nreq := provisioning.StartLocalExecutionRequest{MaxVUs: rawMaxVUs}\n\n// after\nconst maxReasonableVUs = 1_000_000\nif rawMaxVUs <= 0 || rawMaxVUs > maxReasonableVUs {\n\treturn fmt.Errorf(\"invalid max VUs %d\", rawMaxVUs)\n}\nreq := provisioning.StartLocalExecutionRequest{MaxVUs: rawMaxVUs}","handlingStrategy":"validation","validationCode":"const saneMaxVUs = 1 << 20\nif req.MaxVUs <= 0 || req.MaxVUs > saneMaxVUs {\n\treturn fmt.Errorf(\"max_vus %d out of sane range\", req.MaxVUs)\n}","typeGuard":"func fitsInt32(v int64) bool { return v >= math.MinInt32 && v <= math.MaxInt32 }","tryCatchPattern":"if err := client.StartLocalExecution(ctx, id, req); err != nil {\n\tif strings.HasPrefix(err.Error(), \"max_vus:\") {\n\t\t// fix the VU count at its source; do not retry as-is\n\t}\n\treturn err\n}","preventionTips":["Validate resolved options (vus/max-vus) against a realistic bound before provisioning","Range-check values parsed from env vars and flags at parse time","Use k6 inspect to confirm effective options before cloud runs"],"tags":["validation","int32","overflow","vus","options"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}