gofiber/fiber · error
Domain pattern '%s' contains empty parameter name at positio
Error message
Domain pattern '%s' contains empty parameter name at position %d
What it means
Panics from domain.go:94 when a domain parameter is just the colon marker with no name, e.g. a label equal to ":". Parameter labels must be ":name"; a bare ":" has no parameter name to bind and would break DomainParam lookups.
Source
Thrown at domain.go:94
panic(fmt.Sprintf("Domain pattern '%s' has %d parts, which exceeds the maximum of %d",
pattern, len(parts), maxDomainParts))
}
m := domainMatcher{
parts: make([]string, len(parts)),
numParts: len(parts),
}
for i, part := range parts {
// Validate no empty labels (e.g., "example..com" is invalid)
if part == "" {
panic(fmt.Sprintf("Domain pattern '%s' contains empty label at position %d", pattern, i))
}
if part[0] == ':' {
// Validate parameter name is not empty
if len(part) == 1 {
panic(fmt.Sprintf("Domain pattern '%s' contains empty parameter name at position %d", pattern, i))
}
paramName := part[1:]
// Validate parameter name contains only ASCII-safe characters (a-z, A-Z, 0-9, underscore, hyphen).
// Using explicit ASCII ranges rather than unicode.IsLetter/IsDigit to reject non-ASCII
// characters that are invalid in DNS names.
for _, ch := range paramName {
if !isASCIIAlphanumeric(ch) && ch != '_' && ch != '-' {
panic(fmt.Sprintf("Domain pattern '%s' contains invalid parameter name '%s' with character '%c'", pattern, paramName, ch))
}
}
m.paramIdx = append(m.paramIdx, i)
m.paramNames = append(m.paramNames, paramName) // preserve original case
m.parts[i] = part // keep ":param" marker for matching
} else {
// Only lowercase constant labels (RFC 4343)
// Enforce RFC 1035 per-label length limit (63 characters)
if len(part) > 63 {
panic(fmt.Sprintf("Domain pattern '%s' has label '%s' exceeding RFC 1035 limit of 63 characters (%d chars)",View on GitHub (pinned to 9a4c7e57fe)
Solutions
- Give every parameter a name: app.Domain(":tenant.example.com").
- Validate that each ":"-prefixed label has length > 1 before calling Domain().
- Default empty parameter names to a concrete name like "sub".
Example fix
// before
name := params["name"] // ""
app.Domain(":" + name + ".example.com").Get("/", h)
// after
name := params["name"]
if name == "" {
name = "tenant"
}
app.Domain(":" + name + ".example.com").Get("/", h) Defensive patterns
Strategy: validation
Validate before calling
for _, label := range strings.Split(pattern, ".") {
if label == ":" {
return fmt.Errorf("domain parameter missing name")
}
}
app.Domain(pattern).Get("/", h) Prevention
- Never template a ':' without a guaranteed non-empty name.
- Default blank parameter names to a safe constant.
- Validate ':' labels have length > 1.
When it happens
Trigger: app.Domain(":.example.com") - a label that is only ":". Also app.Domain("example.com:") is different (a label ending in colon is treated as constant and fails the character check, not this one); this specific panic is the lone-colon label.
Common situations: Templating that emits ":" + name where name is empty; refactoring parameter naming that left a stray colon; user input used as a parameter name that was blank.
Related errors
- Domain pattern '%s' contains invalid parameter name '%s' wit
- Domain pattern '%s' has %d parameters, which exceeds the max
- Domain pattern cannot be empty
- Domain pattern '%s' exceeds RFC 1035 maximum of 253 characte
- Domain pattern '%s' has %d parts, which exceeds the maximum
AI-assisted analysis of gofiber/fiber@9a4c7e57fe (2026-08-04).
Data as JSON: /data/errors/eea7447685490db8.json.
Report an issue: GitHub.