{"record":{"id":"60fa024014e2b277","repo":"TechnitiumSoftware/DnsServer","slug":"group-name-length-cannot-exceed-255-characters","errorCode":null,"errorMessage":"Group name length cannot exceed 255 characters.","messagePattern":"Group name length cannot exceed 255 characters\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Auth/Group.cs","lineNumber":109,"sourceCode":"        public int CompareTo(Group other)\n        {\n            return _name.CompareTo(other._name);\n        }\n\n        #endregion\n\n        #region properties\n\n        public string Name\n        {\n            get { return _name; }\n            set\n            {\n                if (string.IsNullOrWhiteSpace(value))\n                    throw new ArgumentException(\"Group name cannot be null or empty.\", nameof(Name));\n\n                if (value.Length > 255)\n                    throw new ArgumentException(\"Group name length cannot exceed 255 characters.\", nameof(Name));\n\n                switch (_name?.ToLowerInvariant())\n                {\n                    case \"everyone\":\n                    case \"administrators\":\n                    case \"dns administrators\":\n                    case \"dhcp administrators\":\n                        throw new InvalidOperationException(\"Access was denied.\");\n\n                    default:\n                        _name = value;\n                        break;\n                }\n            }\n        }\n\n        public string Description\n        {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Auth/Group.cs#L91-L127","documentation":"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.","triggerScenarios":"Creating or renaming a Group with a Name longer than 255 chars.","commonSituations":"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.","solutions":["Shorten the group name to <= 255 characters.","Enforce a client-side maxlength and server-side validation on the name field.","If a long identifier is required, store it in Description or a separate attribute."],"exampleFix":"// before\ngroup.Name = name;\n\n// after\nif (name?.Length > 255)\n    return BadRequest(\"Group name length cannot exceed 255 characters.\");\ngroup.Name = name;","handlingStrategy":"validation","validationCode":"if (name is null || name.Length > 255)\n    return BadRequest(\"Group name length cannot exceed 255 characters.\");\ngroup.Name = name;","typeGuard":null,"tryCatchPattern":"try { group.Name = name; }\ncatch (ArgumentException ex) when (ex.ParamName == \"Name\" && ex.Message.Contains(\"255\"))\n{ return BadRequest(ex.Message); }","preventionTips":["Set a maxlength on the name input in the UI.","Validate length server-side before assigning.","Keep group names short and human-readable."],"tags":["groups","validation","length-limit","auth"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}