TechnitiumSoftware/DnsServer · error · DnsWebServiceException

Group already exists: {newGroupName}

Error message

Group already exists: {newGroupName}

What it means

Thrown as DnsWebServiceException from RenameGroup when TryAdd of the new lowercased name fails because it is already taken. The group's Name is reverted to the old value before throwing, and the old key is retained. Returned over the API as HTTP 200 with status 'error'.

Source

Thrown at DnsServerCore/Auth/AuthManager.cs:1092

            throw new DnsWebServiceException("Group already exists: " + name);
        }

        public void RenameGroup(Group group, string newGroupName)
        {
            if (group.Name.Equals(newGroupName, StringComparison.OrdinalIgnoreCase))
            {
                group.Name = newGroupName;
                return;
            }

            string oldGroupName = group.Name;
            group.Name = newGroupName;

            if (!_groups.TryAdd(group.Name.ToLowerInvariant(), group))
            {
                group.Name = oldGroupName; //revert
                throw new DnsWebServiceException("Group already exists: " + newGroupName);
            }

            _groups.TryRemove(oldGroupName.ToLowerInvariant(), out _);

            //update users
            foreach (KeyValuePair<string, User> user in _users)
                user.Value.RenameGroup(oldGroupName);
        }

        public bool DeleteGroup(string name)
        {
            name = name.ToLowerInvariant();

            switch (name)
            {
                case "everyone":
                case "administrators":
                case "dns administrators":

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Pick a target name that does not exist (check case-insensitively).
  2. Delete the conflicting group first if it is not built-in.
  3. Verify the target name with GetGroup before renaming.

Example fix

// before
_authManager.RenameGroup(group, newGroupName);
// after
if (!_groups.ContainsKey(newGroupName.ToLowerInvariant()))
    _authManager.RenameGroup(group, newGroupName);
Defensive patterns

Strategy: validation

Validate before calling

if (await GetGroupAsync(newGroupName) is not null)
    throw new InvalidOperationException($"Group '{newGroupName}' is taken.");

Try / catch

try { await client.RenameGroupAsync(group, newGroupName); }
catch (HttpApiClientException ex) when (ex.Message.StartsWith("Group already exists"))
{
    PromptForDifferentGroupName();
}

Prevention

When it happens

Trigger: POST /api/groups/rename (or equivalent) targeting a newGroupName that already exists; the fast-path no-op only triggers when names are equal OrdinalIgnoreCase.

Common situations: Renaming to collide with an existing group; case-only rename attempt; trying to rename onto a built-in group's name.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/8361a1bbad336b3c. Report an issue: GitHub.