{"record":{"id":"2afb3557382ae1e6","repo":"netbirdio/netbird","slug":"zone-name-is-required","errorCode":null,"errorMessage":"zone name is required","messagePattern":"zone name is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/internals/modules/zones/zone.go","lineNumber":70,"sourceCode":"\t}\n}\n\nfunc (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}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/internals/modules/zones/zone.go#L52-L88","documentation":"zones.Zone.Validate() returns this when Name is empty. A Zone is hydrated from api.ZoneRequest via FromAPIRequest, so a zone create/update without a name hits it. It is the first of four checks (name present, name length, domain format, distribution groups).","triggerScenarios":"POST/PUT of a zone with {\"name\":\"\"} or with the name key missing; building a Zone literal or calling NewZone with an empty name argument.","commonSituations":"Zone-creation form submitted early; a client sending the display name under a different key than the schema's \"name\"; automation that generates zones from templates where the name variable was unset.","solutions":["Supply a non-empty zone name in the request body.","If calling NewZone programmatically, pass a non-empty name string.","Verify the client's field mapping against api.ZoneRequest so \"name\" is populated."],"exampleFix":"// before\n{\"name\": \"\", \"domain\": \"corp.example.com\", \"distribution_groups\": [\"grp-1\"]}\n// after\n{\"name\": \"Corporate\", \"domain\": \"corp.example.com\", \"distribution_groups\": [\"grp-1\"]}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(req.Name) == \"\" {\n    return fmt.Errorf(\"zone name is required\")\n}","typeGuard":"func hasZoneName(req *api.ZoneRequest) bool {\n    return strings.TrimSpace(req.Name) != \"\"\n}","tryCatchPattern":"if err := zone.Validate(); err != nil {\n    return respondBadRequest(err)\n}","preventionTips":["Require the zone name in the creation form before enabling submit.","Check field mapping against api.ZoneRequest when integrating a new client."],"tags":["dns","zones","validation","management-api"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}