{"record":{"id":"619ae281e72e7dd0","repo":"TechnitiumSoftware/DnsServer","slug":"scope-with-name-oldname-does-not-exists","errorCode":null,"errorMessage":"Scope with name '{oldName}' does not exists.","messagePattern":"Scope with name '(.+?)' does not exists\\.","errorType":"exception","errorClass":"DhcpServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/DhcpServer.cs","lineNumber":1446,"sourceCode":"        {\n            await LoadScopeAsync(scope, false);\n            SaveScopeFile(scope);\n        }\n\n        public Scope GetScope(string name)\n        {\n            if (_scopes.TryGetValue(name, out Scope scope))\n                return scope;\n\n            return null;\n        }\n\n        public void RenameScope(string oldName, string newName)\n        {\n            Scope.ValidateScopeName(newName);\n\n            if (!_scopes.TryGetValue(oldName, out Scope scope))\n                throw new DhcpServerException(\"Scope with name '\" + oldName + \"' does not exists.\");\n\n            if (!_scopes.TryAdd(newName, scope))\n                throw new DhcpServerException(\"Scope with name '\" + newName + \"' already exists.\");\n\n            scope.Name = newName;\n            _scopes.TryRemove(oldName, out _);\n\n            SaveScopeFile(scope);\n            DeleteScopeFile(oldName);\n        }\n\n        public void DeleteScope(string name)\n        {\n            if (_scopes.TryGetValue(name, out Scope scope))\n            {\n                UnloadScope(scope, true);\n                DeleteScopeFile(scope.Name);\n            }","sourceCodeStart":1428,"sourceCodeEnd":1464,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/DhcpServer.cs#L1428-L1464","documentation":"RenameScope could not find a scope under oldName in the scopes dictionary, so nothing to rename.","triggerScenarios":"Calling RenameScope(oldName, newName) when `_scopes.TryGetValue(oldName, out _)` is false.","commonSituations":"Stale UI referencing a scope deleted meanwhile. Typo in oldName. Case-sensitivity mismatch (names are treated by dictionary key semantics).","solutions":["Verify the scope exists with GetScope(oldName) before renaming.","Use the exact stored Name (mind casing).","Refresh the scope list in the caller before issuing the rename."],"exampleFix":"// before\n_dhcpServer.RenameScope('Lan', 'lan2'); // stored name is 'lan'\n// after\nvar s = _dhcpServer.GetScope('lan');\nif (s != null) _dhcpServer.RenameScope(s.Name, 'lan2');","handlingStrategy":"validation","validationCode":"if (_dhcpServer.GetScope(oldName) == null)\n    throw new InvalidOperationException($\"Scope '{oldName}' not found\");","typeGuard":"static bool ScopeExists(Func<string, Scope> getScope, string name) => getScope(name) != null;","tryCatchPattern":"try { _dhcpServer.RenameScope(oldName, newName); }\ncatch (DhcpServerException ex) when (ex.Message.Contains(\"does not exists\"))\n{ /* refresh scope list, use exact Name */ }","preventionTips":["Refresh the scope list before rename operations.","Use the exact stored Name (mind casing).","Guard with GetScope before RenameScope."],"tags":["dhcp","scope","validation","not-found"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}