grafana/k6 · error

setupTimeout must be positive

Error message

setupTimeout must be positive

What it means

Options validation error: the setupTimeout option was set to a zero or negative duration. lib.Options.Validate collects it (alongside other validation failures) when building the test run state, because timeouts must be strictly positive durations.

Solutions

  1. Set setupTimeout to a positive duration, e.g. setupTimeout: '30s' in options or --setup-timeout 30s on the CLI
  2. Remove an explicit setupTimeout to fall back to the default instead of overriding it with 0
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/options.go:548 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18). Data as JSON: /api/errors/0724544c67f3a748. Report an issue: GitHub.

Appendix: source

Thrown at lib/options.go:557

	// TODO: validate all of the other options... that we should have already been validating...
	// TODO: maybe integrate an external validation lib: https://github.com/avelino/awesome-go#validation
	var validationErrors []error
	if o.ExecutionSegmentSequence != nil {
		var segmentFound bool
		if slices.ContainsFunc(*o.ExecutionSegmentSequence, o.ExecutionSegment.Equal) {
			segmentFound = true
		}
		if !segmentFound {
			validationErrors = append(validationErrors,
				fmt.Errorf("provided segment %s can't be found in sequence %s",
					o.ExecutionSegment, o.ExecutionSegmentSequence))
		}
	}
	validationErrors = append(validationErrors, o.Scenarios.Validate()...)

	// Duration
	if o.SetupTimeout.Valid && o.SetupTimeout.Duration <= 0 {
		validationErrors = append(validationErrors, errors.New("setupTimeout must be positive"))
	}
	return validationErrors
}

// ForEachSpecified enumerates all struct fields and calls the supplied function with each
// element that is valid. It panics for any unfamiliar or unexpected fields, so make sure
// new fields in Options are accounted for.
func (o Options) ForEachSpecified(structTag string, callback func(key string, value any)) {
	structType := reflect.TypeFor[Options]()
	structVal := reflect.ValueOf(o)
	for i := 0; i < structType.NumField(); i++ {
		fieldType := structType.Field(i)
		fieldVal := structVal.Field(i)
		value := fieldVal.Interface()

		var shouldCall bool
		switch fieldType.Type.Kind() {
		case reflect.Struct:

View on GitHub (pinned to 8d06114777)