{"record":{"id":"90f4d794db0b63b5","repo":"TechnitiumSoftware/DnsServer","slug":"no-such-primary-zone-was-found-zonename","errorCode":null,"errorMessage":"No such primary zone was found: <zoneName>","messagePattern":"No such primary zone was found: <zoneName>","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":1918,"sourceCode":"                            SaveZoneFile(currentCatalogZone.Name);\n                        }\n                    }\n\n                    break;\n\n                default:\n                    throw new NotSupportedException();\n            }\n        }\n\n        #endregion\n\n        #region DNSSEC\n\n        public void SignPrimaryZone(string zoneName, DnssecPrivateKey kskPrivateKey, DnssecPrivateKey zskPrivateKey, uint dnsKeyTtl, bool useNSec3, ushort iterations = 0, byte saltLength = 0)\n        {\n            if (!_root.TryGet(zoneName, out ApexZone apexZone) || (apexZone is not PrimaryZone primaryZone))\n                throw new DnsServerException(\"No such primary zone was found: \" + zoneName);\n\n            primaryZone.SignZone(kskPrivateKey, zskPrivateKey, dnsKeyTtl, useNSec3, iterations, saltLength);\n\n            SaveZoneFile(primaryZone.Name);\n        }\n\n        public void UnsignPrimaryZone(string zoneName)\n        {\n            if (!_root.TryGet(zoneName, out ApexZone apexZone) || (apexZone is not PrimaryZone primaryZone))\n                throw new DnsServerException(\"No such primary zone was found: \" + zoneName);\n\n            primaryZone.UnsignZone();\n\n            SaveZoneFile(primaryZone.Name);\n        }\n\n        public void ConvertPrimaryZoneToNSEC(string zoneName)\n        {","sourceCodeStart":1900,"sourceCodeEnd":1936,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L1900-L1936","documentation":"Thrown by SignPrimaryZone when _root.TryGet cannot find the zone, or the found zone is not a PrimaryZone. DNSSEC signing is only defined for authoritative Primary zones; Secondary/Stub/Forwarder/Catalog zones cannot be signed locally. The combined guard at line 1917 rejects both absence and wrong-type.","triggerScenarios":"Calling SignPrimaryZone(zoneName, ksk, zsk, dnsKeyTtl, useNSec3, iterations, saltLength) where zoneName is unknown or names a non-Primary zone.","commonSituations":"Signing a zone that was converted to Forwarder/Secondary, or deleted. Passing a Secondary zone name to the signing API. Typo or stale cached zone name.","solutions":["Confirm the zone exists and is Primary via GetAuthZoneInfo(zoneName) before signing.","If the zone is not Primary, convert it to Primary with ConvertZoneTypeTo first.","Normalize/trim the zone name and re-resolve.","Catch DnsServerException and report the missing primary zone to the caller."],"exampleFix":"// before\nmanager.SignPrimaryZone(zoneName, ksk, zsk, ttl, false); // throws if not primary\n\n// after\nvar info = manager.GetAuthZoneInfo(zoneName);\nif (info is null || info.Type != AuthZoneType.Primary)\n    return BadRequest($\"'{zoneName}' is not a Primary zone; cannot sign.\");\nmanager.SignPrimaryZone(zoneName, ksk, zsk, ttl, false);","handlingStrategy":"validation","validationCode":"var info = manager.GetAuthZoneInfo(zoneName);\nif (info is null || info.Type != AuthZoneType.Primary)\n    return BadRequest($\"'{zoneName}' is not a Primary zone; cannot sign.\");","typeGuard":"static bool IsPrimaryZone(AuthZoneInfo z) => z?.Type == AuthZoneType.Primary;","tryCatchPattern":"try { manager.SignPrimaryZone(zoneName, ksk, zsk, ttl, false); }\ncatch (DnsServerException ex) when (ex.Message.StartsWith(\"No such primary zone\")) { return NotFound(ex.Message); }","preventionTips":["Resolve and type-check the zone as Primary before signing.","Convert non-Primary zones to Primary before signing.","Refresh zone state before DNSSEC operations."],"tags":["dns","dnssec","signing","primary-zone","not-found"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}