{"record":{"id":"20dc2cfd6f29ecd4","repo":"grafana/k6","slug":"threshold-d-run-error-w","errorCode":null,"errorMessage":"threshold %d run error: %w","messagePattern":"threshold (.+?) run error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds.go","lineNumber":150,"sourceCode":"\nfunc newThresholdsWithConfig(configs []thresholdConfig) Thresholds {\n\tthresholds := make([]*Threshold, len(configs))\n\tsinked := make(map[string]float64)\n\n\tfor i, config := range configs {\n\t\tt := newThreshold(config.Threshold, config.AbortOnFail, config.AbortGracePeriod)\n\t\tthresholds[i] = t\n\t}\n\n\treturn Thresholds{thresholds, false, sinked}\n}\n\nfunc (ts *Thresholds) runAll(timeSpentInTest time.Duration) (bool, error) {\n\tsucceeded := true\n\tfor i, threshold := range ts.Thresholds {\n\t\tb, err := threshold.run(ts.sinked)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"threshold %d run error: %w\", i, err)\n\t\t}\n\n\t\tif !b {\n\t\t\tsucceeded = false\n\n\t\t\tif ts.Abort || !threshold.AbortOnFail {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tts.Abort = !threshold.AbortGracePeriod.Valid ||\n\t\t\t\tthreshold.AbortGracePeriod.Duration < types.Duration(timeSpentInTest)\n\t\t}\n\t}\n\n\treturn succeeded, nil\n}\n\n// Run processes all the thresholds with the provided Sink at the provided time and returns if any","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds.go#L132-L168","documentation":"During Thresholds.runAll, one Threshold.run invocation on the sinked values returned an error, so the whole threshold evaluation aborts and is wrapped with the index of the offending threshold. The underlying error is most often the invalid-operator guard from Threshold.runNoTaint; the index identifies which thresholds[i] failed.","triggerScenarios":"Thrown at metrics/thresholds.go:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Look at the thresholds list in your options at the reported index and fix or remove that threshold expression","Check the wrapped error chain to identify the root cause (usually an invalid operator)","Update k6 if running an old version where operator parsing and evaluation were inconsistent"],"exampleFix":null,"handlingStrategy":"try-catch","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"}