{"record":{"id":"67cfcd54d2ee6750","repo":"TechnitiumSoftware/DnsServer","slug":"group-name-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Group name cannot be null or empty.","messagePattern":"Group name cannot be null or empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Auth/Group.cs","lineNumber":106,"sourceCode":"            return _name;\n        }\n\n        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        }","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Auth/Group.cs#L88-L124","documentation":"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.","triggerScenarios":"Creating or renaming a Group and assigning Name = null, \"\", or a whitespace-only string.","commonSituations":"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.","solutions":["Supply a non-empty, non-whitespace group name.","Validate the name is present in the request payload before constructing/renaming the Group.","Reject blank names at the API boundary with a clear client error."],"exampleFix":"// before\ngroup.Name = name;\n\n// after\nif (string.IsNullOrWhiteSpace(name))\n    return BadRequest(\"Group name cannot be null or empty.\");\ngroup.Name = name;","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(name))\n    return BadRequest(\"Group name cannot be null or empty.\");\ngroup.Name = name;","typeGuard":null,"tryCatchPattern":"try { group.Name = name; }\ncatch (ArgumentException ex) when (ex.ParamName == \"Name\" && ex.Message.Contains(\"null or empty\"))\n{ return BadRequest(ex.Message); }","preventionTips":["Require the name field at the API boundary.","Trim and reject whitespace-only names client-side.","Reject blank names during data import/migration."],"tags":["groups","validation","auth"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}