grafana/k6 · error

stage %d doesn't have a duration

Error message

stage %d doesn't have a duration

What it means

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.

Source

Thrown at lib/executor/helpers.go:46

		if s.Target.Int64 > result {
			result = s.Target.Int64
		}
	}
	return result
}

// A helper function to avoid code duplication
func validateStages(stages []Stage) []error {
	var errors []error
	if len(stages) == 0 {
		errors = append(errors, fmt.Errorf("at least one stage has to be specified"))
		return errors
	}

	for i, s := range stages {
		stageNum := i + 1
		if !s.Duration.Valid {
			errors = append(errors, fmt.Errorf("stage %d doesn't have a duration", stageNum))
		} else if s.Duration.Duration < 0 {
			errors = append(errors, fmt.Errorf("the duration for stage %d can't be negative", stageNum))
		}
		if !s.Target.Valid {
			errors = append(errors, fmt.Errorf("stage %d doesn't have a target", stageNum))
		} else if s.Target.Int64 < 0 {
			errors = append(errors, fmt.Errorf("the target for stage %d can't be negative", stageNum))
		}
	}
	return errors
}

// handleInterrupt returns true if err is InterruptError and if so it
// cancels the executor context passed with ctx.
func handleInterrupt(ctx context.Context, err error) bool {
	if err != nil {
		if errext.IsInterruptError(err) {
			execution.AbortTestRun(ctx, err)

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Add duration to every stage, e.g. { duration: '5m', target: 100 }
  2. Duration accepts strings like '30s', '1m30s'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/executor/helpers.go:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/080866b1948e8321. Report an issue: GitHub.