{"record":{"id":"d9f052ebdc8c096d","repo":"TechnitiumSoftware/DnsServer","slug":"dns-zone-type-not-supported","errorCode":null,"errorMessage":"DNS zone type not supported.","messagePattern":"DNS zone type not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":739,"sourceCode":"\n                case AuthZoneType.SecondaryForwarder:\n                    apexZone = new SecondaryForwarderZone(_dnsServer, zoneInfo);\n                    break;\n\n                case AuthZoneType.Catalog:\n                    apexZone = new CatalogZone(_dnsServer, zoneInfo);\n                    break;\n\n                case AuthZoneType.SecondaryCatalog:\n                    SecondaryCatalogZone secondaryCatalogZone = new SecondaryCatalogZone(_dnsServer, zoneInfo);\n                    secondaryCatalogZone.ZoneAdded += SecondaryCatalogZoneAdded;\n                    secondaryCatalogZone.ZoneRemoved += SecondaryCatalogZoneRemoved;\n\n                    apexZone = secondaryCatalogZone;\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"DNS zone type not supported.\");\n            }\n\n            if (_root.TryAdd(apexZone))\n                return apexZone;\n\n            throw new DnsServerException(\"Zone already exists: \" + zoneInfo.DisplayName);\n        }\n\n        internal AuthZone GetOrAddSubDomainZone(string zoneName, string domain)\n        {\n            return _root.GetOrAddSubDomainZone(zoneName, domain, delegate ()\n            {\n                if (!_root.TryGet(zoneName, out ApexZone apexZone))\n                    throw new DnsServerException(\"Zone was not found for domain: \" + domain);\n\n                if (apexZone is PrimaryZone primaryZone)\n                    return new PrimarySubDomainZone(primaryZone, domain);\n                else if (apexZone is SecondaryCatalogZone secondaryCatalogZone)","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L721-L757","documentation":"Thrown by AuthZoneManager.CreateEmptyApexZone in the default case of its switch over AuthZoneType — the method handles the known zone types (Primary, Secondary, Stub, Forwarder, Catalog, SecondaryCatalog) and throws for any other/unexpected enum value. It guards against an uninitialized or newly added AuthZoneType value that has no apex constructor wired up.","triggerScenarios":"Creating a zone whose AuthZoneInfo.Type is an enum value not covered by CreateEmptyApexZone — e.g. a future/None/unknown value, or a deserialized zone with a corrupt type byte.","commonSituations":"A corrupt zone-info type field from a bad binary file, a code change that added a new AuthZoneType without updating the switch, or deserialization producing an out-of-range enum.","solutions":["Validate AuthZoneInfo.Type is one of the supported values before creating the zone.","If a new zone type was added to the enum, extend CreateEmptyApexZone's switch.","Restore the zone config from a known-good source if the type byte is corrupt."],"exampleFix":"// before\nvar zone = zoneManager.CreateEmptyApexZone(zoneInfo); // unknown type throws\n\n// after\nif (!Enum.IsDefined(typeof(AuthZoneType), zoneInfo.Type) || zoneInfo.Type == AuthZoneType.Unknown)\n    throw new ArgumentException(\"Unsupported zone type: \" + zoneInfo.Type);\nvar zone = zoneManager.CreateEmptyApexZone(zoneInfo);","handlingStrategy":"validation","validationCode":"static readonly HashSet<AuthZoneType> Supported = new()\n{\n    AuthZoneType.Primary, AuthZoneType.Secondary, AuthZoneType.Stub,\n    AuthZoneType.Forwarder, AuthZoneType.Catalog, AuthZoneType.SecondaryCatalog\n};\nbool IsSupportedZoneType(AuthZoneInfo zi) => Supported.Contains(zi.Type);","typeGuard":"static bool IsKnownZoneType(AuthZoneType t) =>\n    t == AuthZoneType.Primary || t == AuthZoneType.Secondary || t == AuthZoneType.Stub ||\n    t == AuthZoneType.Forwarder || t == AuthZoneType.Catalog || t == AuthZoneType.SecondaryCatalog;","tryCatchPattern":"try { zoneManager.CreateEmptyApexZone(zoneInfo); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"zone type not supported\"))\n{\n    // unknown/corrupt type — restore config or reject the request\n}","preventionTips":["Validate AuthZoneInfo.Type against the supported set before creating a zone.","When adding a new AuthZoneType, update CreateEmptyApexZone's switch.","Guard against out-of-range enum values from deserialization (Enum.IsDefined)."],"tags":["dns","csharp","zone-management","enum","technitium"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}