{"record":{"id":"3a33f5afc8677f6b","repo":"netbirdio/netbird","slug":"zone-name-exceeds-maximum-length-of-255-characters","errorCode":null,"errorMessage":"zone name exceeds maximum length of 255 characters","messagePattern":"zone name exceeds maximum length of 255 characters","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/internals/modules/zones/zone.go","lineNumber":73,"sourceCode":"func (z *Zone) FromAPIRequest(req *api.ZoneRequest) {\n\tz.Name = req.Name\n\tz.Domain = req.Domain\n\tz.EnableSearchDomain = req.EnableSearchDomain\n\tz.DistributionGroups = req.DistributionGroups\n\n\tenabled := true\n\tif req.Enabled != nil {\n\t\tenabled = *req.Enabled\n\t}\n\tz.Enabled = enabled\n}\n\nfunc (z *Zone) Validate() error {\n\tif z.Name == \"\" {\n\t\treturn errors.New(\"zone name is required\")\n\t}\n\tif len(z.Name) > 255 {\n\t\treturn errors.New(\"zone name exceeds maximum length of 255 characters\")\n\t}\n\n\tif !domain.IsValidDomainNoWildcard(z.Domain) {\n\t\treturn errors.New(\"invalid zone domain format\")\n\t}\n\n\tif len(z.DistributionGroups) == 0 {\n\t\treturn errors.New(\"at least one distribution group is required\")\n\t}\n\n\treturn nil\n}\n\nfunc (z *Zone) EventMeta() map[string]any {\n\treturn map[string]any{\"name\": z.Name, \"domain\": z.Domain}\n}\n","sourceCodeStart":55,"sourceCodeEnd":90,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/internals/modules/zones/zone.go#L55-L90","documentation":"Zone.Validate() rejects names longer than 255 characters, measured in bytes (len(z.Name)), not runes. This bounds the human-readable zone name, separate from the DNS-compliant Domain field checked next.","triggerScenarios":"A zone create/update whose name string exceeds 255 bytes; names built by concatenating generated identifiers without truncation; multi-byte (unicode) names whose rune count is under 255 but byte count is over.","commonSituations":"Template-generated names embedding long lists or UUIDs; copy-pasting a paragraph into the name field; unicode display names inflating the byte count.","solutions":["Shorten the zone name to at most 255 bytes.","When generating names programmatically, truncate or hash components to a fixed budget.","For unicode names, remember the limit is bytes: budget roughly 3-4 bytes per non-ASCII character."],"exampleFix":"// before\nname := strings.Repeat(\"corp-zone-\", 30) // 300 bytes\n// after\nname := \"corp-zone\" // short, human-readable identifier","handlingStrategy":"validation","validationCode":"if len(req.Name) > 255 {\n    return fmt.Errorf(\"zone name must be at most 255 bytes, got %d\", len(req.Name))\n}","typeGuard":null,"tryCatchPattern":"if err := zone.Validate(); err != nil {\n    return respondBadRequest(err)\n}","preventionTips":["Enforce a client-side character budget well under 255 for generated names.","Remember the check is bytes, so unicode names can exceed it while looking short."],"tags":["dns","zones","validation","limits"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}