{"record":{"id":"e1db3aa5f277f3ad","repo":"grafana/k6","slug":"at-least-one-stage-has-to-be-specified","errorCode":null,"errorMessage":"at least one stage has to be specified","messagePattern":"at least one stage has to be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/helpers.go","lineNumber":39,"sourceCode":"\t}\n\treturn result\n}\n\nfunc getStagesUnscaledMaxTarget(unscaledStartValue int64, stages []Stage) int64 {\n\tresult := unscaledStartValue\n\tfor _, s := range stages {\n\t\tif s.Target.Int64 > result {\n\t\t\tresult = s.Target.Int64\n\t\t}\n\t}\n\treturn result\n}\n\n// A helper function to avoid code duplication\nfunc validateStages(stages []Stage) []error {\n\tvar errors []error\n\tif len(stages) == 0 {\n\t\terrors = append(errors, fmt.Errorf(\"at least one stage has to be specified\"))\n\t\treturn errors\n\t}\n\n\tfor i, s := range stages {\n\t\tstageNum := i + 1\n\t\tif !s.Duration.Valid {\n\t\t\terrors = append(errors, fmt.Errorf(\"stage %d doesn't have a duration\", stageNum))\n\t\t} else if s.Duration.Duration < 0 {\n\t\t\terrors = append(errors, fmt.Errorf(\"the duration for stage %d can't be negative\", stageNum))\n\t\t}\n\t\tif !s.Target.Valid {\n\t\t\terrors = append(errors, fmt.Errorf(\"stage %d doesn't have a target\", stageNum))\n\t\t} else if s.Target.Int64 < 0 {\n\t\t\terrors = append(errors, fmt.Errorf(\"the target for stage %d can't be negative\", stageNum))\n\t\t}\n\t}\n\treturn errors\n}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/executor/helpers.go#L21-L57","documentation":"validateStages was called with an empty stages array. Ramping executors (ramping-vus, ramping-arrival-rate) define their load profile entirely through stages, so at least one stage must be present. The generic helper returns immediately after this error.","triggerScenarios":"Thrown at lib/executor/helpers.go:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add at least one stage, e.g. stages: [{ duration: '1m', target: 20 }]","Or switch to a non-ramping executor if no ramping behavior is needed"],"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"}