{"record":{"id":"080866b1948e8321","repo":"grafana/k6","slug":"stage-d-doesn-t-have-a-duration","errorCode":null,"errorMessage":"stage %d doesn't have a duration","messagePattern":"stage (.+?) doesn't have a duration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/executor/helpers.go","lineNumber":46,"sourceCode":"\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}\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)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/executor/helpers.go#L28-L64","documentation":"validateStages found a stage whose 'duration' property is unset. Each stage must declare how long it lasts (even when target is 0, e.g. for a hold period); the null duration makes the stage unusable for scheduling.","triggerScenarios":"Thrown at lib/executor/helpers.go:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add duration to every stage, e.g. { duration: '5m', target: 100 }","Duration accepts strings like '30s', '1m30s'"],"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"}