{"record":{"id":"2767a496728c1e6c","repo":"grafana/k6","slug":"couldn-t-find-segment-s-in-sequence-s","errorCode":null,"errorMessage":"couldn't find segment %s in sequence %s","messagePattern":"couldn't find segment (.+?) in sequence (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/execution_segment.go","lineNumber":437,"sourceCode":"func (ess ExecutionSegmentSequence) IsFull() bool {\n\treturn len(ess) != 0 && ess[0].from.Cmp(zeroRat) == 0 && ess[len(ess)-1].to.Cmp(oneRat) == 0\n}\n\n// FindSegmentPosition returns the index of the supplied execution segment in\n// the sequence, or an error if the segment isn't present. This shouldn't be\n// used on a nil or empty sequence, it's best to use this method on the result\n// of GetFilledExecutionSegmentSequence().\nfunc (ess ExecutionSegmentSequence) FindSegmentPosition(segment *ExecutionSegment) (int, error) {\n\tfrom := zeroRat\n\tif segment != nil {\n\t\tfrom = segment.from\n\t}\n\tindex := sort.Search(len(ess), func(i int) bool {\n\t\treturn ess[i].from.Cmp(from) >= 0\n\t})\n\n\tif index < 0 || index >= len(ess) || !ess[index].Equal(segment) {\n\t\treturn -1, fmt.Errorf(\"couldn't find segment %s in sequence %s\", segment, ess)\n\t}\n\treturn index, nil\n}\n\n// GetFilledExecutionSegmentSequence makes sure we don't have any gaps in the\n// given execution segment sequence, or a nil one. It makes sure that the whole\n// 0-1 range is filled.\nfunc GetFilledExecutionSegmentSequence(\n\tsequence *ExecutionSegmentSequence, fallback *ExecutionSegment,\n) (result ExecutionSegmentSequence) {\n\tif sequence == nil || len(*sequence) == 0 {\n\t\tif fallback == nil || fallback.length.Cmp(oneRat) == 0 {\n\t\t\t// There is no sequence or a segment, so it means the whole test run\n\t\t\t// is being planned/executed. So we make sure not to have a nil\n\t\t\t// sequence, returning a full; \"0,1\" sequence instead, otherwise we\n\t\t\t// will need to check for nil everywhere...\n\t\t\treturn ExecutionSegmentSequence{newExecutionSegment(zeroRat, oneRat)}\n\t\t}","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/execution_segment.go#L419-L455","documentation":"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).","triggerScenarios":"Thrown at lib/execution_segment.go:437 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}