TechnitiumSoftware/DnsServer · error · ArgumentException

Group name cannot be null or empty.

Error message

Group name cannot be null or empty.

What it means

Thrown by the Group.Name setter when the new value is null, empty, or whitespace. It is an ArgumentException because a group must have a non-blank name. This guard runs first, before the length and reserved-name checks.

Source

Thrown at DnsServerCore/Auth/Group.cs:106

            return _name;
        }

        public int CompareTo(Group other)
        {
            return _name.CompareTo(other._name);
        }

        #endregion

        #region properties

        public string Name
        {
            get { return _name; }
            set
            {
                if (string.IsNullOrWhiteSpace(value))
                    throw new ArgumentException("Group name cannot be null or empty.", nameof(Name));

                if (value.Length > 255)
                    throw new ArgumentException("Group name length cannot exceed 255 characters.", nameof(Name));

                switch (_name?.ToLowerInvariant())
                {
                    case "everyone":
                    case "administrators":
                    case "dns administrators":
                    case "dhcp administrators":
                        throw new InvalidOperationException("Access was denied.");

                    default:
                        _name = value;
                        break;
                }
            }
        }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Supply a non-empty, non-whitespace group name.
  2. Validate the name is present in the request payload before constructing/renaming the Group.
  3. Reject blank names at the API boundary with a clear client error.

Example fix

// before
group.Name = name;

// after
if (string.IsNullOrWhiteSpace(name))
    return BadRequest("Group name cannot be null or empty.");
group.Name = name;
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(name))
    return BadRequest("Group name cannot be null or empty.");
group.Name = name;

Try / catch

try { group.Name = name; }
catch (ArgumentException ex) when (ex.ParamName == "Name" && ex.Message.Contains("null or empty"))
{ return BadRequest(ex.Message); }

Prevention

When it happens

Trigger: Creating or renaming a Group and assigning Name = null, "", or a whitespace-only string.

Common situations: A create-group API call missing the name field; a form submitted with an empty name; an import/migration row with a blank group name.

Related errors


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