{"id":"1c90db8fc96b251c","repo":"gofiber/fiber","slug":"domain-pattern-s-has-label-s-exceeding-rfc-1","errorCode":null,"errorMessage":"Domain pattern '%s' has label '%s' exceeding RFC 1035 limit of 63 characters (%d chars)","messagePattern":"Domain pattern '(.+?)' has label '(.+?)' exceeding RFC 1035 limit of 63 characters \\((.+?) chars\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"domain.go","lineNumber":112,"sourceCode":"\t\t\t\tpanic(fmt.Sprintf(\"Domain pattern '%s' contains empty parameter name at position %d\", pattern, i))\n\t\t\t}\n\t\t\tparamName := part[1:]\n\t\t\t// Validate parameter name contains only ASCII-safe characters (a-z, A-Z, 0-9, underscore, hyphen).\n\t\t\t// Using explicit ASCII ranges rather than unicode.IsLetter/IsDigit to reject non-ASCII\n\t\t\t// characters that are invalid in DNS names.\n\t\t\tfor _, ch := range paramName {\n\t\t\t\tif !isASCIIAlphanumeric(ch) && ch != '_' && ch != '-' {\n\t\t\t\t\tpanic(fmt.Sprintf(\"Domain pattern '%s' contains invalid parameter name '%s' with character '%c'\", pattern, paramName, ch))\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.paramIdx = append(m.paramIdx, i)\n\t\t\tm.paramNames = append(m.paramNames, paramName) // preserve original case\n\t\t\tm.parts[i] = part                              // keep \":param\" marker for matching\n\t\t} else {\n\t\t\t// Only lowercase constant labels (RFC 4343)\n\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}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/domain.go#L94-L130","documentation":"Panics from domain.go:112 when a constant (non-parameter) label exceeds the RFC 1035 per-label limit of 63 characters. Long labels are not matchable by any real DNS name and signal a malformed or adversarial pattern.","triggerScenarios":"app.Domain(\"<64+chars>.example.com\"); a single label built by padding or concatenation that crosses 63 chars.","commonSituations":"Hashes, base64 blobs, or IDs used as a domain label; generated patterns with unbounded label length; test fixtures.","solutions":["Keep constant labels at or under 63 characters.","Validate each label's length before registering the domain route.","Move overlong identifiers into path segments or headers instead of the hostname."],"exampleFix":"// before\nlabel := base64.RawURLEncoding.EncodeToString(blob) // > 63\napp.Domain(label + \".example.com\").Get(\"/\", h)\n\n// after\nlabel := shorten(blob) // ensure <= 63 chars\nif len(label) > 63 {\n    return fmt.Errorf(\"label too long\")\n}\napp.Domain(label + \".example.com\").Get(\"/\", h)","handlingStrategy":"validation","validationCode":"for _, label := range strings.Split(pattern, \".\") {\n    if !strings.HasPrefix(label, \":\") && len(label) > 63 {\n        return fmt.Errorf(\"domain label exceeds 63 chars: %s\", label)\n    }\n}\napp.Domain(pattern).Get(\"/\", h)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep constant labels under 63 chars.","Avoid embedding hashes/base64 blobs in hostnames.","Move overlong IDs to path segments."],"tags":["routing","domain","validation","rfc-1035","panic"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}