{"record":{"id":"f10eb152dedd0211","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-create-more-than-255-groups","errorCode":null,"errorMessage":"Cannot create more than 255 groups.","messagePattern":"Cannot create more than 255 groups\\.","errorType":"exception","errorClass":"DnsWebServiceException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Auth/AuthManager.cs","lineNumber":1060,"sourceCode":"\n        public void SyncGroupMembers(Group group, IReadOnlyDictionary<string, User> users)\n        {\n            //remove\n            foreach (KeyValuePair<string, User> user in _users)\n            {\n                if (!users.ContainsKey(user.Key))\n                    user.Value.RemoveFromGroup(group);\n            }\n\n            //set\n            foreach (KeyValuePair<string, User> user in users)\n                user.Value.AddToGroup(group);\n        }\n\n        public Group CreateGroup(string name, string description)\n        {\n            if (_groups.Count >= byte.MaxValue)\n                throw new DnsWebServiceException(\"Cannot create more than 255 groups.\");\n\n            Group group = new Group(name, description);\n\n            if (_groups.TryAdd(name.ToLowerInvariant(), group))\n            {\n                if (_groups.Count > byte.MaxValue)\n                {\n                    _groups.TryRemove(name.ToLowerInvariant(), out _); //undo\n                    throw new DnsWebServiceException(\"Cannot create more than 255 groups.\");\n                }\n\n                return group;\n            }\n\n            throw new DnsWebServiceException(\"Group already exists: \" + name);\n        }\n\n        public void RenameGroup(Group group, string newGroupName)","sourceCodeStart":1042,"sourceCodeEnd":1078,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Auth/AuthManager.cs#L1042-L1078","documentation":"Thrown as DnsWebServiceException from CreateGroup when _groups.Count >= 255 (byte.MaxValue) before adding. Group identifiers are stored as a byte, hence the 255 cap. Returned over the API as HTTP 200 with status 'error'.","triggerScenarios":"POST /api/groups/create (or equivalent) when 255 groups already exist; the pre-add guard fails fast.","commonSituations":"Bulk group creation; long-lived server that accumulated groups up to the cap.","solutions":["Delete unused groups to free slots below 255.","Reorganize permissions to need fewer groups.","Check the group count before bulk-provisioning."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (await GetGroupCountAsync() >= 255)\n    throw new InvalidOperationException(\"Group cap (255) reached; delete unused groups first.\");","typeGuard":null,"tryCatchPattern":"try { await client.CreateGroupAsync(name, description); }\ncatch (HttpApiClientException ex) when (ex.Message.Contains(\"Cannot create more than 255 groups\"))\n{\n    await FreeUpGroupSlotsAsync();\n}","preventionTips":["Consolidate permissions into fewer groups.","Track group count during bulk setup."],"tags":["auth","group-management","limits"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}