{"id":"b763513a2f9ed0c0","repo":"gofiber/fiber","slug":"domain-pattern-s-has-d-parameters-which-excee","errorCode":null,"errorMessage":"Domain pattern '%s' has %d parameters, which exceeds the maximum of %d","messagePattern":"Domain pattern '(.+?)' has (.+?) parameters, which exceeds the maximum of (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"domain.go","lineNumber":128,"sourceCode":"\t\t\t// Enforce RFC 1035 per-label length limit (63 characters)\n\t\t\tif len(part) > 63 {\n\t\t\t\tpanic(fmt.Sprintf(\"Domain pattern '%s' has label '%s' exceeding RFC 1035 limit of 63 characters (%d chars)\",\n\t\t\t\t\tpattern, part, len(part)))\n\t\t\t}\n\t\t\t// Validate label contains only valid ASCII domain characters (a-z, 0-9, hyphen).\n\t\t\tnormalized := utilsstrings.ToLower(part)\n\t\t\tfor _, ch := range normalized {\n\t\t\t\tif !isASCIIAlphanumeric(ch) && ch != '-' {\n\t\t\t\t\tpanic(fmt.Sprintf(\"Domain pattern '%s' contains invalid character '%c' in label '%s'\", pattern, ch, part))\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.parts[i] = normalized\n\t\t}\n\t}\n\n\t// Check if the domain pattern has too many parameters\n\tif len(m.paramNames) > maxParams {\n\t\tpanic(fmt.Sprintf(\"Domain pattern '%s' has %d parameters, which exceeds the maximum of %d\",\n\t\t\tpattern, len(m.paramNames), maxParams))\n\t}\n\n\treturn m\n}\n\n// match checks if a hostname matches the domain pattern.\n// It returns true if matched and a slice of parameter values (parallel to paramNames).\n// Uses a stack-allocated buffer to avoid heap allocation for typical domain names.\n// Validates hostname to prevent DoS attacks from malicious input.\nfunc (m *domainMatcher) match(hostname string) (bool, []string) { //nolint:gocritic // unnamedResult: named returns conflict with nonamedreturns linter\n\t// Trim trailing dot of a fully-qualified domain name (RFC 3986),\n\t// consistent with Fiber's own host normalization in Subdomains().\n\thostname = utils.TrimRight(hostname, '.')\n\n\t// Validate hostname is not empty and not excessively long (DoS protection)\n\t// RFC 1035 limits domain names to 253 characters\n\tif hostname == \"\" || len(hostname) > 253 {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/domain.go#L110-L146","documentation":"Panics from domain.go:128 when a domain pattern declares more than maxParams (30) parameters. This cap (shared with path parameters, ctx.go:32) bounds the fixed-size parameter array in the request context; exceeding it would overflow that storage.","triggerScenarios":"app.Domain(\":a.:b.:c....example.com\") with more than 30 ':'-prefixed labels in a single domain pattern.","commonSituations":"Machine-generated patterns that parameterize every label; misusing domain parameters to encode many tenants; a loop that appends \":x\" labels.","solutions":["Reduce the number of domain parameters to 30 or fewer.","Capture only the variable labels you actually need; keep the rest constant.","Move per-label variability into path routing or a lookup keyed on a single domain param."],"exampleFix":"// before\npat := strings.Join(labels, \".\") // > 30 ':' params\napp.Domain(pat).Get(\"/\", h)\n\n// after - keep essential params, fix the rest\nconstLabels := []string{\"svc\", \"example\", \"com\"}\npat := \":tenant.\" + strings.Join(constLabels, \".\")\napp.Domain(pat).Get(\"/\", h)","handlingStrategy":"validation","validationCode":"n := 0\nfor _, label := range strings.Split(pattern, \".\") {\n    if strings.HasPrefix(label, \":\") {\n        n++\n    }\n}\nif n > 30 {\n    return fmt.Errorf(\"domain pattern has %d parameters, max 30\", n)\n}\napp.Domain(pattern).Get(\"/\", h)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Parameterize only the labels you need; keep the rest constant.","Cap generated parameter counts at 30.","Move per-label variability to path routing or a lookup table."],"tags":["routing","domain","validation","parameter","limits","panic"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}