grafana/k6 · error

segment end value can't be more than 1 but was %s

Error message

segment end value can't be more than 1 but was %s

What it means

NewExecutionSegment rejected a segment whose 'to' rational exceeds 1. It is the final boundary check of 0 <= from < to <= 1; segments represent fractions of the total workload and can never extend past 100%.

Source

Thrown at lib/execution_segment.go:57

// Helpful "constants" so we don't initialize them in every function call
var (
	zeroRat, oneRat      = big.NewRat(0, 1), big.NewRat(1, 1) //nolint:gochecknoglobals
	oneBigInt, twoBigInt = big.NewInt(1), big.NewInt(2)       //nolint:gochecknoglobals
)

// NewExecutionSegment validates the supplied arguments (basically, that 0 <=
// from < to <= 1) and either returns an error, or it returns a
// fully-initialized and usable execution segment.
func NewExecutionSegment(from, to *big.Rat) (*ExecutionSegment, error) {
	if from.Cmp(zeroRat) < 0 {
		return nil, fmt.Errorf("segment start value must be at least 0 but was %s", from.FloatString(2))
	}
	if from.Cmp(to) >= 0 {
		return nil, fmt.Errorf("segment start(%s) must be less than its end(%s)", from.FloatString(2), to.FloatString(2))
	}
	if to.Cmp(oneRat) > 0 {
		return nil, fmt.Errorf("segment end value can't be more than 1 but was %s", to.FloatString(2))
	}
	return newExecutionSegment(from, to), nil
}

// newExecutionSegment just creates an ExecutionSegment without validating the arguments
func newExecutionSegment(from, to *big.Rat) *ExecutionSegment {
	return &ExecutionSegment{
		from:   from,
		to:     to,
		length: new(big.Rat).Sub(to, from),
	}
}

// stringToRat is a helper function that tries to convert a string to a rational
// number while allowing percentage, decimal, and fraction values.
func stringToRat(s string) (*big.Rat, error) {
	if before, ok := strings.CutSuffix(s, "%"); ok {
		num, ok := new(big.Int).SetString(before, 10)

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Keep segment end points <= 1, e.g. 1/2:1
  2. Express smaller slices with fractions like 0:1/4 instead of values above 1
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/execution_segment.go:57 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/e57be14531473a3f. Report an issue: GitHub.