{"record":{"id":"8e4f98cd04f5d7c6","repo":"grafana/k6","slug":"the-number-of-preallocatedvus-can-t-be-negative","errorCode":null,"errorMessage":"the number of preAllocatedVUs can't be negative","messagePattern":"the number of preAllocatedVUs can't be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/constant_arrival_rate.go","lineNumber":114,"sourceCode":"\t\terrors = append(errors, fmt.Errorf(\"the iteration rate must be more than 0\"))\n\t}\n\n\tif carc.TimeUnit.TimeDuration() <= 0 {\n\t\terrors = append(errors, fmt.Errorf(\"the timeUnit must be more than 0\"))\n\t}\n\n\tif !carc.Duration.Valid {\n\t\terrors = append(errors, fmt.Errorf(\"the duration is unspecified\"))\n\t} else if carc.Duration.TimeDuration() < minDuration {\n\t\terrors = append(errors, fmt.Errorf(\n\t\t\t\"the duration must be at least %s, but is %s\", minDuration, carc.Duration,\n\t\t))\n\t}\n\n\tif !carc.PreAllocatedVUs.Valid {\n\t\terrors = append(errors, fmt.Errorf(\"the number of preAllocatedVUs isn't specified\"))\n\t} else if carc.PreAllocatedVUs.Int64 < 0 {\n\t\terrors = append(errors, fmt.Errorf(\"the number of preAllocatedVUs can't be negative\"))\n\t}\n\n\tif !carc.MaxVUs.Valid {\n\t\t// TODO: don't change the config while validating\n\t\tcarc.MaxVUs.Int64 = carc.PreAllocatedVUs.Int64\n\t} else if carc.MaxVUs.Int64 < carc.PreAllocatedVUs.Int64 {\n\t\terrors = append(errors, fmt.Errorf(\"maxVUs can't be less than preAllocatedVUs\"))\n\t}\n\n\treturn errors\n}\n\n// GetExecutionRequirements returns the number of required VUs to run the\n// executor for its whole duration (disregarding any startTime), including the\n// maximum waiting time for any iterations to gracefully stop. This is used by\n// the execution scheduler in its VU reservation calculations, so it knows how\n// many VUs to pre-initialize.\nfunc (carc ConstantArrivalRateConfig) GetExecutionRequirements(et *lib.ExecutionTuple) []lib.ExecutionStep {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/executor/constant_arrival_rate.go#L96-L132","documentation":"ConstantArrivalRateConfig.Validate rejected a negative preAllocatedVUs value. Pre-allocated VUs are a count of initialized VUs and cannot be negative; zero is allowed but means all VUs are booted lazily at runtime.","triggerScenarios":"Thrown at lib/executor/constant_arrival_rate.go:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set preAllocatedVUs to 0 or a positive number","If it was omitted, set it explicitly — but the error means it was present and negative, so fix the sign"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}