{"record":{"id":"87d58d8c8c35b24f","repo":"grafana/k6","slug":"segment-start-value-must-be-at-least-0-but-was-s","errorCode":null,"errorMessage":"segment start value must be at least 0 but was %s","messagePattern":"segment start value must be at least 0 but was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/execution_segment.go","lineNumber":51,"sourceCode":"\n// Ensure we implement those interfaces\nvar (\n\t_ encoding.TextUnmarshaler = &ExecutionSegment{}\n\t_ fmt.Stringer             = &ExecutionSegment{}\n)\n\n// Helpful \"constants\" so we don't initialize them in every function call\nvar (\n\tzeroRat, oneRat      = big.NewRat(0, 1), big.NewRat(1, 1) //nolint:gochecknoglobals\n\toneBigInt, twoBigInt = big.NewInt(1), big.NewInt(2)       //nolint:gochecknoglobals\n)\n\n// NewExecutionSegment validates the supplied arguments (basically, that 0 <=\n// from < to <= 1) and either returns an error, or it returns a\n// fully-initialized and usable execution segment.\nfunc NewExecutionSegment(from, to *big.Rat) (*ExecutionSegment, error) {\n\tif from.Cmp(zeroRat) < 0 {\n\t\treturn nil, fmt.Errorf(\"segment start value must be at least 0 but was %s\", from.FloatString(2))\n\t}\n\tif from.Cmp(to) >= 0 {\n\t\treturn nil, fmt.Errorf(\"segment start(%s) must be less than its end(%s)\", from.FloatString(2), to.FloatString(2))\n\t}\n\tif to.Cmp(oneRat) > 0 {\n\t\treturn nil, fmt.Errorf(\"segment end value can't be more than 1 but was %s\", to.FloatString(2))\n\t}\n\treturn newExecutionSegment(from, to), nil\n}\n\n// newExecutionSegment just creates an ExecutionSegment without validating the arguments\nfunc newExecutionSegment(from, to *big.Rat) *ExecutionSegment {\n\treturn &ExecutionSegment{\n\t\tfrom:   from,\n\t\tto:     to,\n\t\tlength: new(big.Rat).Sub(to, from),\n\t}\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/lib/execution_segment.go#L33-L69","documentation":"NewExecutionSegment rejected a segment whose 'from' rational is negative. It is the first of three boundary checks (0 <= from < to <= 1); this one fires when the lower bound of the segment is below zero, which can only come from a bad --execution-segment value or programmatic misuse.","triggerScenarios":"Thrown at lib/execution_segment.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a start value >= 0, e.g. 0:1/2 for the first half of the test","Check the --execution-segment CLI flag or segment strings in options for a leading negative value"],"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-14T00:17:10.932Z"}