grafana/k6 · error
couldn't find segment %s in sequence %s
Error message
couldn't find segment %s in sequence %s
What it means
FindSegmentPosition searched the sorted segment sequence and did not find a segment equal to the supplied one. NewExecutionTuple calls this to determine a segment's ordinal for striping; failure means the segment is not part of the sequence being queried (e.g. mismatched --execution-segment and --execution-segment-sequence).
Source
Thrown at lib/execution_segment.go:437
func (ess ExecutionSegmentSequence) IsFull() bool {
return len(ess) != 0 && ess[0].from.Cmp(zeroRat) == 0 && ess[len(ess)-1].to.Cmp(oneRat) == 0
}
// FindSegmentPosition returns the index of the supplied execution segment in
// the sequence, or an error if the segment isn't present. This shouldn't be
// used on a nil or empty sequence, it's best to use this method on the result
// of GetFilledExecutionSegmentSequence().
func (ess ExecutionSegmentSequence) FindSegmentPosition(segment *ExecutionSegment) (int, error) {
from := zeroRat
if segment != nil {
from = segment.from
}
index := sort.Search(len(ess), func(i int) bool {
return ess[i].from.Cmp(from) >= 0
})
if index < 0 || index >= len(ess) || !ess[index].Equal(segment) {
return -1, fmt.Errorf("couldn't find segment %s in sequence %s", segment, ess)
}
return index, nil
}
// GetFilledExecutionSegmentSequence makes sure we don't have any gaps in the
// given execution segment sequence, or a nil one. It makes sure that the whole
// 0-1 range is filled.
func GetFilledExecutionSegmentSequence(
sequence *ExecutionSegmentSequence, fallback *ExecutionSegment,
) (result ExecutionSegmentSequence) {
if sequence == nil || len(*sequence) == 0 {
if fallback == nil || fallback.length.Cmp(oneRat) == 0 {
// There is no sequence or a segment, so it means the whole test run
// is being planned/executed. So we make sure not to have a nil
// sequence, returning a full; "0,1" sequence instead, otherwise we
// will need to check for nil everywhere...
return ExecutionSegmentSequence{newExecutionSegment(zeroRat, oneRat)}
}View on GitHub (pinned to 01ffac6f24)
Solutions
- Ensure the --execution-segment value is one of the segments in the --execution-segment-sequence
- Leave the sequence unspecified so k6 derives it from the segment automatically
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/execution_segment.go:437 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/2767a496728c1e6c.
Report an issue: GitHub.