grafana/k6 · error

at least one stage has to be specified

Error message

at least one stage has to be specified

What it means

validateStages was called with an empty stages array. Ramping executors (ramping-vus, ramping-arrival-rate) define their load profile entirely through stages, so at least one stage must be present. The generic helper returns immediately after this error.

Source

Thrown at lib/executor/helpers.go:39

	}
	return result
}

func getStagesUnscaledMaxTarget(unscaledStartValue int64, stages []Stage) int64 {
	result := unscaledStartValue
	for _, s := range stages {
		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
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Add at least one stage, e.g. stages: [{ duration: '1m', target: 20 }]
  2. Or switch to a non-ramping executor if no ramping behavior is needed
Defensive patterns

Strategy: validation

When it happens

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