{"record":{"id":"0eb7795bf9e42d88","repo":"grafana/k6","slug":"failed-parsing-threshold-expression-q-reason-w","errorCode":null,"errorMessage":"failed parsing threshold expression %q; reason: %w","messagePattern":"failed parsing threshold expression %q; reason: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds_parser.go","lineNumber":77,"sourceCode":"// ```\n// assertion           -> aggregation_method whitespace* operator whitespace* float\n// aggregation_method  -> trend | rate | gauge | counter\n// counter             -> \"count\" | \"rate\"\n// gauge               -> \"value\"\n// 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","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds_parser.go#L59-L95","documentation":"The first stage of parseThresholdExpression — scanThresholdExpression — failed on the quoted input: the string could not be split into 'aggregation_method operator value'. Usually the operator token is missing or not one of the recognized tokens, or the right-hand side is empty.","triggerScenarios":"Thrown at metrics/thresholds_parser.go:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include a valid comparison operator: > >= <= < == === !=","Provide a right-hand-side numeric value after the operator (e.g. 'p(95)<400' not 'p(95)<')","Quote threshold keys in YAML so expressions are not mangled by the parser"],"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"}