{"record":{"id":"f2c514efdecb7104","repo":"gofiber/fiber","slug":"route-s-has-d-parameters-which-exceeds-the-ma","errorCode":null,"errorMessage":"Route '%s' has %d parameters, which exceeds the maximum of %d","messagePattern":"Route '(.+?)' has (.+?) parameters, which exceeds the maximum of (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"path.go","lineNumber":364,"sourceCode":"\tparser.minSlashes = int32(minSlashes)\n\tif bounded {\n\t\tparser.maxSlashes = int32(maxSlashes)\n\t\tparser.maxBounded = true\n\t}\n}\n\n// parseRoute analyzes the route and divides it into segments for constant areas and parameters,\n// this information is needed later when assigning the requests to the declared routes\nfunc parseRoute(pattern string, regexHandler any, customConstraints ...CustomConstraint) routeParser {\n\tparser := routeParser{}\n\tparser.parseRoute(pattern, regexHandler, customConstraints...)\n\t// The slash bounds only speed up the router's candidate scan; computing them\n\t// here keeps them off RoutePatternMatch's per-call path, which never reads them.\n\tparser.computeSlashBounds()\n\n\t// Check if the route has too many parameters\n\tif len(parser.params) > maxParams {\n\t\tpanic(fmt.Sprintf(\"Route '%s' has %d parameters, which exceeds the maximum of %d\",\n\t\t\tpattern, len(parser.params), maxParams))\n\t}\n\n\treturn parser\n}\n\n// addParameterMetaInfo add important meta information to the parameter segments\n// to simplify the search for the end of the parameter\nfunc addParameterMetaInfo(segs []*routeSegment) []*routeSegment {\n\tvar comparePart string\n\tsegLen := len(segs)\n\t// loop from end to begin\n\tfor i := segLen - 1; i >= 0; i-- {\n\t\t// set the compare part for the parameter\n\t\tif segs[i].IsParam {\n\t\t\t// important for finding the end of the parameter\n\t\t\tsegs[i].ComparePart = RemoveEscapeChar(comparePart)\n\t\t} else {","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/path.go#L346-L382","documentation":"parseRoute caps the number of path parameters per route pattern at maxParams (30). Each :param, {param}, or *wildcard segment counts as one parameter. Exceeding 30 panics with the pattern, the actual count, and the limit. The cap exists because the router stores parameters in a fixed-size stack array ([maxParams]string) on the context for zero-allocation matching, so the route parser enforces the same bound the matcher assumes.","triggerScenarios":"Registering a route like app.Get(\"/:a/:b/:c/.../:ae\", ...) with more than 30 parameter segments; a generated route (e.g. from a deeply nested resource path) that accumulates parameters past the limit.","commonSituations":"A programmatically-generated route with many nested resource IDs; a route built by joining many path fragments each carrying a parameter; exceeding the limit after adding a new parameterized segment to an already-long route.","solutions":["Reduce the number of path parameters to 30 or fewer by collapsing redundant segments (e.g. move some identifiers into query parameters or a nested resource under a single prefix).","If the long path is unavoidable, split the route across multiple handlers or use a catch-all (* wildcard counts as one) to absorb a variable tail.","Audit generated routes for parameter count before registering them."],"exampleFix":"// before — 31 params, panics\napp.Get(\"/:a/:b/:c/:d/:e/:f/:g/:h/:i/:j/:k/:l/:m/:n/:o/:p/:q/:r/:s/:t/:u/:v/:w/:x/:y/:z/:aa/:ab/:ac/:ad/:ae\", h)\n\n// after — collapse the tail into a catch-all wildcard\napp.Get(\"/:a/:b/:c/.../:z/*rest\", h)","handlingStrategy":"validation","validationCode":"const maxRouteParams = 30\n\nfunc countRouteParams(pattern string) int {\n    n := 0\n    for i := 0; i < len(pattern); i++ {\n        switch pattern[i] {\n        case ':', '*':\n            n++\n        case '{':\n            if strings.ContainsRune(pattern[i:], '}') { n++ }\n        }\n    }\n    return n\n}\n// if countRouteParams(pattern) > maxRouteParams { refactor before registering }","typeGuard":"func routeWithinParamLimit(pattern string) bool { return countRouteParams(pattern) <= 30 }","tryCatchPattern":null,"preventionTips":["Audit generated/templated routes for parameter count before registering them.","Prefer query parameters or catch-all wildcards for deeply variable paths.","Keep maxParams (30) in mind when designing nested resource routes."],"tags":["router","config","panic","routing"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}