{"record":{"id":"16255b26c58f0857","repo":"grafana/k6","slug":"archive-size-w","errorCode":null,"errorMessage":"archive_size: %w","messagePattern":"archive_size: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/api.go","lineNumber":218,"sourceCode":"\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\n\tres, hr, err := c.apiClient.ProvisioningAPI.\n\t\tStartLocalExecutionTest(c.authCtx(ctx), loadTestID).\n\t\tK6IdempotencyKey(hex.EncodeToString(key[:])).\n\t\tStartLocalExecutionTestRequest(sdkReq).\n\t\tExecute()\n\tdefer closeResponse(hr, &err)\n\n\tif hr != nil {\n\t\tif respErr := CheckResponse(hr); respErr != nil {\n\t\t\treturn nil, respErr\n\t\t}\n\t}","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/provisioning/api.go#L200-L236","documentation":"Returned by Client.StartLocalExecution (internal/cloudapi/provisioning/api.go:218) when req.ArchiveSize (bytes, int64) exceeds int32 because the SDK's archive_size field is int32. This is the one overflow in this group that real workloads can hit: an archive larger than 2,147,483,647 bytes (~2 GiB) cannot be described to the backend. Note the 0 case is legal (means 'no archive', sent as JSON null), so only >2 GiB archives fail.","triggerScenarios":"Running with an archive whose serialized tar exceeds ~2 GiB: huge data files, node_modules-scale directories, or binary assets bundled next to the script, with archive upload enabled.","commonSituations":"Script directories containing large fixtures/datasets committed for local testing; multi-file monorepos archived wholesale; workflows that never pruned generated artifacts.","solutions":["Check the archive size before starting: if it exceeds 2 GiB, reduce it — remove non-script assets, .k6ignore-style pruning, or restructure so the test reads data from an object store at runtime instead of shipping it in the archive.","If the script is self-contained, run with --no-archive-upload so ArchiveSize is 0 and no upload happens.","Log the size and largest files: 'du -sh' over the script tree / inspect the tarball to find what bloats it.","Guard at the call site (see defense code) so the failure message is actionable before hitting the API."],"exampleFix":"// before\nresp, err := c.StartLocalExecution(ctx, id, provisioning.StartLocalExecutionRequest{ArchiveSize: int64(len(archiveBytes))})\n\n// after — fail fast with guidance before calling the API\nconst maxArchiveBytes = int64(2147483647) // int32 limit\nsize := int64(len(archiveBytes))\nif size > maxArchiveBytes {\n\treturn fmt.Errorf(\"archive is %d bytes (> 2 GiB limit); remove large assets or use --no-archive-upload\", size)\n}\nresp, err := c.StartLocalExecution(ctx, id, provisioning.StartLocalExecutionRequest{ArchiveSize: size})","handlingStrategy":"validation","validationCode":"const maxArchiveBytes = int64(math.MaxInt32) // 2 GiB SDK limit\n\nfunc validArchiveSize(size int64) bool {\n\treturn size == 0 || size <= maxArchiveBytes // 0 = no archive upload\n}\n\nif !validArchiveSize(int64(len(archiveBytes))) {\n\treturn fmt.Errorf(\"archive is %d bytes (> 2 GiB); prune assets or use --no-archive-upload\", len(archiveBytes))\n}","typeGuard":null,"tryCatchPattern":"if _, err := c.StartLocalExecution(ctx, id, req); err != nil {\n\tif strings.Contains(err.Error(), \"archive_size\") && strings.Contains(err.Error(), \"overflows int32\") {\n\t\t// archive too large to describe to the API — shrink it; retrying cannot help\n\t\treturn errors.New(\"archive exceeds 2 GiB cloud limit; remove large files or disable archive upload\")\n\t}\n}","preventionTips":["Keep script directories free of large datasets/binaries; load test data from external storage at runtime.","Check archive size programmatically right after serialization, before provisioning.","For self-contained scripts, prefer --no-archive-upload to skip the size and upload entirely."],"tags":["k6","cloud","provisioning","integer-overflow","archive","size-limit"],"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"}