{"record":{"id":"f1ddaa62cecb0bc3","repo":"grafana/k6","slug":"malformed-percentile-value-provide-a-number-betwe","errorCode":null,"errorMessage":"malformed percentile value, provide a number between 0 and 100","messagePattern":"malformed percentile value, provide a number between 0 and 100","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds_parser.go","lineNumber":207,"sourceCode":"// it verbatim, as a string.\nfunc parseThresholdAggregationMethod(input string) (string, null.Float, error) {\n\t// Is the input one of the methods keywords?\n\tfor _, m := range aggregationMethodTokens {\n\t\t// Percentile expressions being of the form p(value),\n\t\t// they won't be matched here.\n\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":189,"sourceCodeEnd":219,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds_parser.go#L189-L219","documentation":"The percentile value inside p(...) parsed as a float but is outside the valid range: it is NaN, negative, or greater than 100. Percentiles are interpreted as values between 0 and 100.","triggerScenarios":"Thrown at metrics/thresholds_parser.go:207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a percentile between 0 and 100 inclusive, e.g. p(90), p(95), p(99)","For fractional percentiles keep them within range, e.g. p(99.9)"],"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"}