{"record":{"id":"dcfb61eda6308a1b","repo":"TechnitiumSoftware/DnsServer","slug":"group-already-exists-name","errorCode":null,"errorMessage":"Group already exists: {name}","messagePattern":"Group already exists: (.+?)","errorType":"exception","errorClass":"DnsWebServiceException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Auth/AuthManager.cs","lineNumber":1075,"sourceCode":"        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)\n        {\n            if (group.Name.Equals(newGroupName, StringComparison.OrdinalIgnoreCase))\n            {\n                group.Name = newGroupName;\n                return;\n            }\n\n            string oldGroupName = group.Name;\n            group.Name = newGroupName;\n\n            if (!_groups.TryAdd(group.Name.ToLowerInvariant(), group))\n            {\n                group.Name = oldGroupName; //revert\n                throw new DnsWebServiceException(\"Group already exists: \" + newGroupName);\n            }","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Auth/AuthManager.cs#L1057-L1093","documentation":"Thrown as DnsWebServiceException from CreateGroup when _groups.TryAdd(name.ToLowerInvariant(), group) returns false because a group with that name already exists. Group keys are stored lowercased, so the check is case-insensitive. Returned over the API as HTTP 200 with status 'error'.","triggerScenarios":"Creating a group whose lowercased name matches an existing group key; case-only differences collide.","commonSituations":"Re-running a setup script; a built-in group like 'everyone' or 'administrators' already exists with the target name.","solutions":["Check whether the group exists (case-insensitively) before creating.","Choose a unique group name.","Delete the existing group first (note: built-in groups cannot be deleted)."],"exampleFix":"// before\n_authManager.CreateGroup(name, description);\n// after\nif (!_groups.ContainsKey(name.ToLowerInvariant()))\n    _authManager.CreateGroup(name, description);","handlingStrategy":"validation","validationCode":"if (await GetGroupAsync(name) is not null)\n    throw new InvalidOperationException($\"Group '{name}' already exists.\");","typeGuard":null,"tryCatchPattern":"try { await client.CreateGroupAsync(name, description); }\ncatch (HttpApiClientException ex) when (ex.Message.StartsWith(\"Group already exists\"))\n{\n    // use existing group instead\n}","preventionTips":["Check group existence case-insensitively before creating.","Avoid colliding with built-in group names."],"tags":["auth","group-management","duplicate"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}