{"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/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/path.go#L346-L382","documentation":"parseRoute enforces a hard cap (maxParams = 30) on the number of path parameters in a single route pattern, because the router pre-allocates parameter storage sized to this limit. A pattern with more than 30 parameters panics at registration with the route, the count, and the maximum.","triggerScenarios":"Registering a route like app.Get(\"/:a/:b/:c/.../:ae\", ...) with more than 30 parameter segments. Also triggered by wildcard/greedy parameters if they each count toward the limit, or by code-generated routes from a schema with many dynamic fields.","commonSituations":"Auto-generating routes from a database schema or OpenAPI spec with many path params. Building a search/filter URL that encodes each filter as a param. Migration from a router without such a limit.","solutions":["Reduce the number of path parameters to 30 or fewer by moving extra values into query parameters or the request body.","Consolidate related params into a single segment parsed inside the handler.","If you genuinely need more, restructure the API into nested sub-routes."],"exampleFix":"// before\napp.Get(\"/:a/:b/:c/:d/.../:ag\", handler)\n// after\napp.Get(\"/search\", handler) // pass filters as query params: /search?a=1&b=2...","handlingStrategy":"validation","validationCode":"// maxParams mirrors the internal router cap (30)\nconst routeParamCap = 30\nfunc countParams(pattern string) int {\n    n := 0\n    for i := 0; i < len(pattern); i++ {\n        if pattern[i] == ':' || pattern[i] == '*' {\n            n++\n        }\n    }\n    return n\n}\nif countParams(pattern) > routeParamCap {\n    log.Fatalf(\"route %q exceeds the %d parameter cap; move extras to query/body\", pattern, routeParamCap)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep dynamic values in query parameters or the request body rather than the path.","When generating routes from a schema, assert the param count stays within 30 before registering."],"tags":["routing","path","parameters","limit","panic"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}