{"record":{"id":"e6abddb3b541d245","repo":"grafana/k6","slug":"value-d-overflows-int32","errorCode":null,"errorMessage":"value %d overflows int32","messagePattern":"value (.+?) overflows int32","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/api.go","lineNumber":298,"sourceCode":"\t\t\t\tPushPeriodSeconds: l.GetPushPeriodSeconds(),\n\t\t\t\tMessageMaxSize:    l.GetMessageMaxSize(),\n\t\t\t\tAllowedLabels:     l.GetAllowedLabels(),\n\t\t\t},\n\t\t},\n\t}\n\n\tif url := res.ArchiveUploadUrl.Get(); url != nil {\n\t\tresp.ArchiveUploadURL = url\n\t}\n\n\treturn resp\n}\n\n// toInt32 safely converts an int64 to int32, returning an error if\n// the value overflows.\nfunc toInt32(v int64) (int32, error) {\n\tif v < math.MinInt32 || v > math.MaxInt32 {\n\t\treturn 0, fmt.Errorf(\"value %d overflows int32\", v)\n\t}\n\treturn int32(v), nil\n}\n\n// closeResponse drains and closes an HTTP response body. It mirrors\n// the v6 package's closeResponse helper.\nfunc closeResponse(res *http.Response, rerr *error) {\n\tif res == nil {\n\t\treturn\n\t}\n\t_, _ = io.Copy(io.Discard, res.Body)\n\tif err := res.Body.Close(); err != nil && *rerr == nil {\n\t\t*rerr = err\n\t}\n}\n","sourceCodeStart":280,"sourceCodeEnd":314,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/provisioning/api.go#L280-L314","documentation":"The primitive overflow error from toInt32 (internal/cloudapi/provisioning/api.go:298): a value passed into StartLocalExecution (max_vus, total_duration, or archive_size) is outside the int32 range [-2147483648, 2147483647] that the k6 Cloud OpenAPI SDK requires. Callers normally see it wrapped with a field-name prefix ('max_vus: value 2147483648 overflows int32'), which tells you which field overflowed. It is a hard pre-flight rejection — no HTTP request is made.","triggerScenarios":"req.MaxVUs, req.TotalDuration, or req.ArchiveSize (only when > 0) exceeding math.MaxInt32 or dropping below math.MinInt32 at the toInt32 call sites in StartLocalExecution (api.go:204, 208, 216).","commonSituations":"The realistic case is ArchiveSize > ~2 GiB; the other two almost always indicate unit confusion or -1 sentinels from the calling code; SDK clients in other languages mapping these fields to 64-bit ints and forwarding unchecked values.","solutions":["Read the field name in the wrapped message to identify which value overflowed, then inspect how the caller computed it.","For archive_size: shrink the archive or use --no-archive-upload (0 → JSON null is valid).","For durations/VUs: verify units (seconds, count) and replace sentinel negatives with real computed values.","Add range validation at the request-construction site so the failure surfaces with context before StartLocalExecution."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Central guard for all int32-bound request fields.\nfunc fitsInt32(v int64) bool {\n\treturn v >= math.MinInt32 && v <= math.MaxInt32\n}\n\nfor name, v := range map[string]int64{\n\t\"max_vus\": req.MaxVUs, \"total_duration\": req.TotalDuration, \"archive_size\": req.ArchiveSize,\n} {\n\tif !fitsInt32(v) {\n\t\treturn fmt.Errorf(\"%s=%d exceeds int32 range; check how this value is computed\", name, v)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if _, err := c.StartLocalExecution(ctx, id, req); err != nil {\n\tif strings.Contains(err.Error(), \"overflows int32\") {\n\t\t// permanent input error — locate the offending field from the prefix and fix upstream\n\t\treturn err\n\t}\n}","preventionTips":["Range-check every numeric field at the API boundary where the request struct is built.","Remember the SDK models max_vus, total_duration and archive_size as int32 even though the structs use int64.","Treat any overflow as a computation bug (units/sentinels), never as a transient failure to retry."],"tags":["k6","cloud","provisioning","integer-overflow","int32","validation"],"backgroundTag":"integer-overflow","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"}