{"record":{"id":"6bb282c3864048a2","repo":"grafana/k6","slug":"stage-d-doesn-t-have-a-target","errorCode":null,"errorMessage":"stage %d doesn't have a target","messagePattern":"stage (.+?) doesn't have a target","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/helpers.go","lineNumber":51,"sourceCode":"}\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}\n\n// handleInterrupt returns true if err is InterruptError and if so it\n// cancels the executor context passed with ctx.\nfunc handleInterrupt(ctx context.Context, err error) bool {\n\tif err != nil {\n\t\tif errext.IsInterruptError(err) {\n\t\t\texecution.AbortTestRun(ctx, err)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/executor/helpers.go#L33-L69","documentation":"validateStages found a stage missing the 'target' property. Every stage must state the VU (or arrival-rate) level it ramps to — including target: 0 for ramp-down to zero; omitting it leaves the stage's goal undefined.","triggerScenarios":"Thrown at lib/executor/helpers.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add target to each stage, e.g. { duration: '2m', target: 50 }","Use target: 0 explicitly for ramping down to no load"],"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-14T05:17:10.506Z"}