grafana/k6 · error

stage %d doesn't have a target

Error message

stage %d doesn't have a target

What it means

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.

Source

Thrown at lib/executor/helpers.go:51

}

// 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)
			return true
		}
	}
	return false
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Add target to each stage, e.g. { duration: '2m', target: 50 }
  2. Use target: 0 explicitly for ramping down to no load
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/executor/helpers.go:51 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/6bb282c3864048a2. Report an issue: GitHub.