{"record":{"id":"ab3a184f2453ba51","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-clone-the-zone-source-zone-must-be-a-prima","errorCode":null,"errorMessage":"Cannot clone the zone: source zone must be a Primary or Conditional Forwarder zone.","messagePattern":"Cannot clone the zone: source zone must be a Primary or Conditional Forwarder zone\\.","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":1319,"sourceCode":"        {\n            AuthZoneInfo sourceZoneInfo = GetAuthZoneInfo(sourceZoneName);\n            if (sourceZoneInfo is null)\n                throw new DnsServerException(\"No such zone was found: \" + (sourceZoneName.Length == 0 ? \".\" : sourceZoneName));\n\n            AuthZoneInfo zoneInfo;\n\n            switch (sourceZoneInfo.Type)\n            {\n                case AuthZoneType.Primary:\n                    zoneInfo = CreatePrimaryZone(zoneName);\n                    break;\n\n                case AuthZoneType.Forwarder:\n                    zoneInfo = CreateForwarderZone(zoneName);\n                    break;\n\n                default:\n                    throw new DnsServerException(\"Cannot clone the zone: source zone must be a Primary or Conditional Forwarder zone.\");\n            }\n\n            if (zoneInfo is null)\n                throw new DnsServerException(\"Failed to clone the zone: zone already exists.\");\n\n            //copy zone options\n            zoneInfo.Disabled = sourceZoneInfo.Disabled;\n\n            if (zoneInfo.Type == AuthZoneType.Primary)\n            {\n                zoneInfo.ZoneTransfer = sourceZoneInfo.ZoneTransfer;\n                zoneInfo.ZoneTransferNetworkACL = sourceZoneInfo.ZoneTransferNetworkACL;\n                zoneInfo.ZoneTransferTsigKeyNames = sourceZoneInfo.ZoneTransferTsigKeyNames;\n\n                zoneInfo.Notify = sourceZoneInfo.Notify;\n                zoneInfo.NotifyNameServers = sourceZoneInfo.NotifyNameServers;\n\n                zoneInfo.Update = sourceZoneInfo.Update;","sourceCodeStart":1301,"sourceCodeEnd":1337,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L1301-L1337","documentation":"Thrown by CloneZone's switch default when sourceZoneInfo.Type is neither Primary nor Forwarder. The clone operation only knows how to reproduce authoritative Primary zones and Conditional Forwarder zones; Secondary, Stub, SecondaryForwarder, Catalog and SecondaryCatalog source types are rejected because their data is non-authoritative or structurally incompatible with a fresh clone.","triggerScenarios":"Calling CloneZone with a source zone whose AuthZoneType is Secondary, SecondaryForwarder, SecondaryCatalog, Stub, or Catalog. The switch at line 1308 only whitelists AuthZoneType.Primary and AuthZoneType.Forwarder; everything else hits default at line 1318.","commonSituations":"Trying to duplicate a Secondary zone that is populated by zone transfer from a primary master. Attempting to clone a Catalog zone or a Stub zone. UI that offers 'clone' for every zone type in the list.","solutions":["Choose a Primary or Conditional Forwarder zone as the clone source; convert it first if needed.","If you need a copy of a Secondary zone, create a new Secondary zone pointing at the same primary instead of cloning.","Disable/redirect the 'Clone' action in the UI for non-Primary/non-Forwarder zone types.","Pre-validate sourceZoneInfo.Type == AuthZoneType.Primary || == AuthZoneType.Forwarder before calling CloneZone."],"exampleFix":"// before\nmanager.CloneZone(newName, sourceZone.Name); // source is Secondary -> throws\n\n// after\nif (sourceZone.Type != AuthZoneType.Primary && sourceZone.Type != AuthZoneType.Forwarder)\n    return BadRequest(\"Only Primary or Conditional Forwarder zones can be cloned.\");\nmanager.CloneZone(newName, sourceZone.Name);","handlingStrategy":"validation","validationCode":"if (source.Type != AuthZoneType.Primary && source.Type != AuthZoneType.Forwarder)\n    return BadRequest(\"Only Primary or Conditional Forwarder zones can be cloned.\");","typeGuard":"static bool IsCloneable(AuthZoneType t) => t is AuthZoneType.Primary or AuthZoneType.Forwarder;","tryCatchPattern":"catch (DnsServerException ex) when (ex.Message.Contains(\"source zone must be\")) { return BadRequest(ex.Message); }","preventionTips":["Restrict the 'Clone' UI action to Primary and Forwarder zones.","Pre-validate the source type before calling CloneZone.","Document the supported clone sources in the API contract."],"tags":["dns","zone-management","clone","unsupported-type"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}