{"record":{"id":"61b481149b5d3aa9","repo":"grafana/k6","slug":"failed-parsing-threshold-expression-s-q-left-hand","errorCode":null,"errorMessage":"failed parsing threshold expression's %q left hand side; reason: %w","messagePattern":"failed parsing threshold expression's %q left hand side; reason: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds_parser.go","lineNumber":82,"sourceCode":"// rate                -> \"rate\"\n// trend               -> \"avg\" | \"min\" | \"max\" | \"med\" | percentile\n// percentile          -> \"p(\" float \")\"\n// operator            -> \">\" | \">=\" | \"<=\" | \"<\" | \"==\" | \"===\" | \"!=\"\n// float               -> digit+ (\".\" digit+)?\n// digit               -> \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\"\n// whitespace          -> \" \"\n// ```\nfunc parseThresholdExpression(input string) (*thresholdExpression, error) {\n\t// Scanning makes no assumption on the underlying values, and only\n\t// checks that the expression has the right format.\n\tmethod, operator, value, err := scanThresholdExpression(input)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed parsing threshold expression %q; reason: %w\", input, err)\n\t}\n\n\tparsedMethod, parsedMethodValue, err := parseThresholdAggregationMethod(method)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed parsing threshold expression's %q left hand side; \"+\n\t\t\t\"reason: %w\", input, err,\n\t\t)\n\t\treturn nil, err\n\t}\n\n\tparsedValue, err := strconv.ParseFloat(value, 64)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed parsing threshold expresion's %q right hand side; \"+\n\t\t\t\"reason: %w\", input, err,\n\t\t)\n\t\treturn nil, err\n\t}\n\n\tcondition := &thresholdExpression{\n\t\tAggregationMethod: parsedMethod,\n\t\tAggregationValue:  parsedMethodValue,\n\t\tOperator:          operator,\n\t\tValue:             parsedValue,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds_parser.go#L64-L100","documentation":"The left-hand side of the threshold expression (the aggregation method) failed to parse via parseThresholdAggregationMethod. It is not one of the keywords (avg, min, max, med, count, rate, value) nor a well-formed percentile expression p(number). The wrapping keeps the whole quoted expression for context.","triggerScenarios":"Thrown at metrics/thresholds_parser.go:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported aggregation method: avg, min, max, med, count, rate, value, or p(N)","For percentiles use the exact form p(95) with a number between 0 and 100","Match the method to the metric type: trend supports avg/min/max/med/p(N), counter supports count/rate, gauge supports value, rate supports rate"],"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"}