{"record":{"id":"54a0436cf92d3759","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-convert-the-zone-currentzoneinfo-displayn","errorCode":null,"errorMessage":"Cannot convert the zone '<currentZoneInfo.DisplayName>' from <currentZoneInfo.TypeName> to <AuthZoneInfo.GetZoneTypeName(newType)> zone: the zone is already of the same type.","messagePattern":"Cannot convert the zone '<currentZoneInfo\\.DisplayName>' from <currentZoneInfo\\.TypeName> to <AuthZoneInfo\\.GetZoneTypeName\\(newType\\)> zone: the zone is already of the same type\\.","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":1442,"sourceCode":"\n            //load and init zone\n            LoadAndInitZone(zoneInfo, newRecords);\n\n            //save zone file\n            SaveZoneFile(zoneInfo.Name);\n\n            return zoneInfo;\n        }\n\n        public AuthZoneInfo ConvertZoneTypeTo(string zoneName, AuthZoneType newType)\n        {\n            AuthZoneInfo currentZoneInfo = GetAuthZoneInfo(zoneName);\n            if (currentZoneInfo is null)\n                throw new DnsServerException(\"No such zone was found: \" + (zoneName.Length == 0 ? \".\" : zoneName));\n\n            //validate conversion type\n            if (currentZoneInfo.Type == newType)\n                throw new DnsServerException(\"Cannot convert the zone '\" + currentZoneInfo.DisplayName + \"' from \" + currentZoneInfo.TypeName + \" to \" + AuthZoneInfo.GetZoneTypeName(newType) + \" zone: the zone is already of the same type.\");\n\n            switch (currentZoneInfo.Type)\n            {\n                case AuthZoneType.Primary:\n                    switch (newType)\n                    {\n                        case AuthZoneType.Forwarder:\n                            if (currentZoneInfo.ApexZone.DnssecStatus != AuthZoneDnssecStatus.Unsigned)\n                                throw new DnsServerException(\"Cannot convert the zone '\" + currentZoneInfo.DisplayName + \"' from \" + currentZoneInfo.TypeName + \" to \" + AuthZoneInfo.GetZoneTypeName(newType) + \" zone: converting the zone will cause lose of DNSSEC private keys.\");\n\n                            break;\n\n                        default:\n                            throw new DnsServerException(\"Cannot convert the zone '\" + currentZoneInfo.DisplayName + \"' from \" + currentZoneInfo.TypeName + \" to \" + AuthZoneInfo.GetZoneTypeName(newType) + \" zone: not supported.\");\n                    }\n\n                    break;\n","sourceCodeStart":1424,"sourceCodeEnd":1460,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L1424-L1460","documentation":"Thrown by ConvertZoneTypeTo when currentZoneInfo.Type equals newType, i.e. the requested conversion is a no-op. The guard at line 1441 short-circuits before any structural switch because converting a zone to its own type is meaningless and would otherwise churn records.","triggerScenarios":"Calling ConvertZoneTypeTo with a newType that is identical to the zone's current AuthZoneType. For example calling ConvertZoneTypeTo(\"example.com\", AuthZoneType.Primary) on a zone that is already Primary.","commonSituations":"UI defaulting the target-type selector to the current type. Scripted bulk-convert that doesn't skip already-matching zones. Stale cached zone info used to decide the conversion target.","solutions":["Skip the call when currentZoneInfo.Type == newType.","Initialize the conversion target selector to a different type than the current one.","Refresh zone metadata so the decision is based on live state.","Catch and treat as a no-op warning rather than an error in orchestration scripts."],"exampleFix":"// before\nmanager.ConvertZoneTypeTo(zoneName, desiredType); // throws if same type\n\n// after\nvar info = manager.GetAuthZoneInfo(zoneName);\nif (info.Type == desiredType)\n    return; // nothing to do\nmanager.ConvertZoneTypeTo(zoneName, desiredType);","handlingStrategy":"validation","validationCode":"var info = manager.GetAuthZoneInfo(zoneName);\nif (info.Type == newType) return; // no-op, skip convert","typeGuard":null,"tryCatchPattern":"catch (DnsServerException ex) when (ex.Message.Contains(\"already of the same type\")) { /* treat as success/no-op */ }","preventionTips":["Skip conversion when current and target types match.","Default the target-type selector to a different type than current.","Base conversion decisions on freshly loaded zone metadata."],"tags":["dns","zone-management","convert","no-op","input-validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}