{"record":{"id":"8b11307bc3f9bde8","repo":"netbirdio/netbird","slug":"at-least-one-distribution-group-is-required","errorCode":null,"errorMessage":"at least one distribution group is required","messagePattern":"at least one distribution group is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"management/internals/modules/zones/zone.go","lineNumber":81,"sourceCode":"\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":63,"sourceCodeEnd":90,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/internals/modules/zones/zone.go#L63-L90","documentation":"The last check in Zone.Validate(): DistributionGroups must contain at least one group ID. Zones distribute resolved DNS to peers through distribution groups, so a zone with no groups has no consumers and is rejected. Group existence is validated elsewhere; here only non-emptiness is enforced.","triggerScenarios":"Zone create/update with distribution_groups omitted, set to [], or to [\"\"]; constructing a Zone via NewZone with a nil or empty slice.","commonSituations":"Forgetting the field on first zone creation; passing group names instead of IDs and an empty ID list; clients treating the field as optional because the OpenAPI marks other fields optional.","solutions":["Include at least one existing group ID in distribution_groups, e.g. [\"grp-1\"].","Create the distribution group first if none exists yet, then reference its ID.","If calling NewZone, pass a non-empty []string of group IDs."],"exampleFix":"// before\n{\"name\": \"Corp\", \"domain\": \"corp.example.com\", \"distribution_groups\": []}\n// after\n{\"name\": \"Corp\", \"domain\": \"corp.example.com\", \"distribution_groups\": [\"grp-1\"]}","handlingStrategy":"validation","validationCode":"if len(req.DistributionGroups) == 0 {\n    return fmt.Errorf(\"at least one distribution group is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := zone.Validate(); err != nil {\n    return respondBadRequest(err)\n}","preventionTips":["Create the distribution group before the zone and pass its ID.","Send group IDs, not names, in distribution_groups."],"tags":["dns","zones","groups","validation"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}