{"record":{"id":"91f7d82ad116ed9b","repo":"grafana/k6","slug":"error-for-stage-d-w","errorCode":null,"errorMessage":"error for stage %d: %w","messagePattern":"error for stage (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/options.go","lineNumber":123,"sourceCode":"\t\tNoConnectionReuse:       getNullBool(flags, \"no-connection-reuse\"),\n\t\tNoVUConnectionReuse:     getNullBool(flags, \"no-vu-connection-reuse\"),\n\t\tMinIterationDuration:    getNullDuration(flags, \"min-iteration-duration\"),\n\t\tThrow:                   getNullBool(flags, \"throw\"),\n\t\tDiscardResponseBodies:   getNullBool(flags, \"discard-response-bodies\"),\n\t\tMetricSamplesBufferSize: null.NewInt(1000, false),\n\t}\n\n\t// Using Changed() because GetStringSlice() doesn't differentiate between empty and no value\n\tif flags.Changed(\"stage\") {\n\t\tstageStrings, err := flags.GetStringSlice(\"stage\")\n\t\tif err != nil {\n\t\t\treturn opts, err\n\t\t}\n\t\topts.Stages = []lib.Stage{}\n\t\tfor i, s := range stageStrings {\n\t\t\tvar stage lib.Stage\n\t\t\tif err := stage.UnmarshalText([]byte(s)); err != nil {\n\t\t\t\treturn opts, fmt.Errorf(\"error for stage %d: %w\", i, err)\n\t\t\t}\n\t\t\tif !stage.Duration.Valid {\n\t\t\t\treturn opts, fmt.Errorf(\"stage %d doesn't have a specified duration\", i)\n\t\t\t}\n\t\t\topts.Stages = append(opts.Stages, stage)\n\t\t}\n\t}\n\n\tif flags.Changed(\"execution-segment\") {\n\t\texecutionSegmentStr, err := flags.GetString(\"execution-segment\")\n\t\tif err != nil {\n\t\t\treturn opts, err\n\t\t}\n\t\tsegment := new(lib.ExecutionSegment)\n\t\terr = segment.UnmarshalText([]byte(executionSegmentStr))\n\t\tif err != nil {\n\t\t\treturn opts, err\n\t\t}","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/cmd/options.go#L105-L141","documentation":"Wrapped error while parsing a --stage flag value in getOptions: the i-th stage string could not be unmarshalled by lib.Stage.UnmarshalText — the 'duration:ramp' style syntax is malformed. The index in the message identifies which --stage entry is at fault.","triggerScenarios":"Thrown at internal/cmd/options.go:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use correct stage syntax, e.g. --stage 30s:10 or 1m:20","Check the stage index in the message to find the offending flag value","Fix the JSON/text stage definitions in options.stages in the script"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}