{"record":{"id":"c54fd79434ba40dc","repo":"grafana/k6","slug":"invalid-trend-stat-s-unknown-format","errorCode":null,"errorMessage":"invalid trend stat '%s', unknown format","messagePattern":"invalid trend stat '(.+?)', unknown format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/sample.go","lineNumber":176,"sourceCode":"\t\tif staticStat, ok := staticResolvers[stat]; ok {\n\t\t\tresult[stat] = staticStat\n\t\t\tcontinue\n\t\t}\n\n\t\tpercentile, err := parsePercentile(stat)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tresult[stat] = dynamicResolver(percentile)\n\t}\n\n\treturn result, nil\n}\n\n// parsePercentile is a helper function to parse and validate percentile notations\nfunc parsePercentile(stat string) (float64, error) {\n\tif !strings.HasPrefix(stat, \"p(\") || !strings.HasSuffix(stat, \")\") {\n\t\treturn 0, fmt.Errorf(\"invalid trend stat '%s', unknown format\", stat)\n\t}\n\n\tpercentile, err := strconv.ParseFloat(stat[2:len(stat)-1], 64)\n\n\tif err != nil || (percentile < 0) || (percentile > 100) {\n\t\treturn 0, fmt.Errorf(\"invalid percentile trend stat value '%s', provide a number between 0 and 100\", stat)\n\t}\n\n\treturn percentile, nil\n}\n","sourceCodeStart":158,"sourceCodeEnd":187,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/sample.go#L158-L187","documentation":"Raised by parsePercentile (used for trend column stats, e.g. summaryTrendStats) when a stat is neither a known static stat (avg, min, med, max, count) nor a percentile of the form p(N). It is a format guard for the trend-stat notation.","triggerScenarios":"Thrown at metrics/sample.go:176 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use static stats (avg, min, med, max, count) or percentile notation like p(95)","Check for typos such as p95 without parentheses"],"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"}