grafana/k6 · error
stage doesn't have a specified duration
Error message
stage %d doesn't have a specified duration
What it means
Validation error for the i-th --stage value: the stage parsed but has no duration specified. Stages require a duration (e.g. '30s:10'); a target-only stage is rejected because stage length is mandatory when the stage flag is used.
Solutions
- Add a duration to the stage, e.g. --stage 30s:10
- Use --duration for a simple constant-VU run instead of stages
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/cmd/options.go:117 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/746ec0cdd946ea67.
Report an issue: GitHub.
Appendix: source
Thrown at internal/cmd/options.go:126
Throw: getNullBool(flags, "throw"),
DiscardResponseBodies: getNullBool(flags, "discard-response-bodies"),
MetricSamplesBufferSize: null.NewInt(1000, false),
}
// Using Changed() because GetStringSlice() doesn't differentiate between empty and no value
if flags.Changed("stage") {
stageStrings, err := flags.GetStringSlice("stage")
if err != nil {
return opts, err
}
opts.Stages = []lib.Stage{}
for i, s := range stageStrings {
var stage lib.Stage
if err := stage.UnmarshalText([]byte(s)); err != nil {
return opts, fmt.Errorf("error for stage %d: %w", i, err)
}
if !stage.Duration.Valid {
return opts, fmt.Errorf("stage %d doesn't have a specified duration", i)
}
opts.Stages = append(opts.Stages, stage)
}
}
if flags.Changed("execution-segment") {
executionSegmentStr, err := flags.GetString("execution-segment")
if err != nil {
return opts, err
}
segment := new(lib.ExecutionSegment)
err = segment.UnmarshalText([]byte(executionSegmentStr))
if err != nil {
return opts, err
}
opts.ExecutionSegment = segment
}
View on GitHub (pinned to 8d06114777)