{"record":{"id":"03033626175081de","repo":"grafana/k6","slug":"failed-parsing-method-from-expression","errorCode":null,"errorMessage":"failed parsing method from expression","messagePattern":"failed parsing method from expression","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds_parser.go","lineNumber":213,"sourceCode":"\t\tif m == input {\n\t\t\treturn m, null.Float{}, nil\n\t\t}\n\t}\n\n\t// Otherwise, attempt to parse a percentile expression\n\tif strings.HasPrefix(input, tokenPercentile+\"(\") && strings.HasSuffix(input, \")\") {\n\t\taggregationValue, err := strconv.ParseFloat(trimDelimited(\"p(\", input, \")\"), 64)\n\t\tif err != nil {\n\t\t\treturn \"\", null.Float{}, fmt.Errorf(\"malformed percentile value; reason: %w\", err)\n\t\t}\n\t\tif math.IsNaN(aggregationValue) || aggregationValue < 0 || aggregationValue > 100 {\n\t\t\treturn \"\", null.Float{}, fmt.Errorf(\"malformed percentile value, provide a number between 0 and 100\")\n\t\t}\n\n\t\treturn tokenPercentile, null.FloatFrom(aggregationValue), nil\n\t}\n\n\treturn \"\", null.Float{}, fmt.Errorf(\"failed parsing method from expression\")\n}\n\nfunc trimDelimited(prefix, input, suffix string) string {\n\treturn strings.TrimSuffix(strings.TrimPrefix(input, prefix), suffix)\n}\n","sourceCodeStart":195,"sourceCodeEnd":219,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds_parser.go#L195-L219","documentation":"parseThresholdAggregationMethod could not recognize the left-hand side: the input is neither one of the aggregation method keywords nor a percentile expression of the form p(number). Generic guard for any unrecognized aggregation method token in the threshold expression.","triggerScenarios":"Thrown at metrics/thresholds_parser.go:213 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the supported methods: avg, min, max, med, count, rate, value, or p(N)","Check spelling and casing of the method name","Confirm the method applies to the metric type the threshold is set on"],"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-14T05:17:10.506Z"}