TechnitiumSoftware/DnsServer · error · ArgumentException

Group name length cannot exceed 255 characters.

Error message

Group name length cannot exceed 255 characters.

What it means

Thrown by the Group.Name setter when the new value exceeds 255 characters (after the null/empty check passes). It is an ArgumentException enforcing the configured storage width for group names.

Source

Thrown at DnsServerCore/Auth/Group.cs:109

        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;
                }
            }
        }

        public string Description
        {

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Shorten the group name to <= 255 characters.
  2. Enforce a client-side maxlength and server-side validation on the name field.
  3. If a long identifier is required, store it in Description or a separate attribute.

Example fix

// before
group.Name = name;

// after
if (name?.Length > 255)
    return BadRequest("Group name length cannot exceed 255 characters.");
group.Name = name;
Defensive patterns

Strategy: validation

Validate before calling

if (name is null || name.Length > 255)
    return BadRequest("Group name length cannot exceed 255 characters.");
group.Name = name;

Try / catch

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

Prevention

When it happens

Trigger: Creating or renaming a Group with a Name longer than 255 chars.

Common situations: A UI that does not enforce a maxlength on the name field; a migration that concatenates hierarchical group paths into one name; a script that builds names from long identifiers.

Related errors


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