TechnitiumSoftware/DnsServer · error · InvalidDataException

DNS zone type not supported.

Error message

DNS zone type not supported.

What it means

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.

Solutions

  1. Validate AuthZoneInfo.Type is one of the supported values before creating the zone.
  2. If a new zone type was added to the enum, extend CreateEmptyApexZone's switch.
  3. Restore the zone config from a known-good source if the type byte is corrupt.

Example fix

// before
var zone = zoneManager.CreateEmptyApexZone(zoneInfo); // unknown type throws

// after
if (!Enum.IsDefined(typeof(AuthZoneType), zoneInfo.Type) || zoneInfo.Type == AuthZoneType.Unknown)
    throw new ArgumentException("Unsupported zone type: " + zoneInfo.Type);
var zone = zoneManager.CreateEmptyApexZone(zoneInfo);
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<AuthZoneType> Supported = new()
{
    AuthZoneType.Primary, AuthZoneType.Secondary, AuthZoneType.Stub,
    AuthZoneType.Forwarder, AuthZoneType.Catalog, AuthZoneType.SecondaryCatalog
};
bool IsSupportedZoneType(AuthZoneInfo zi) => Supported.Contains(zi.Type);

Type guard

static bool IsKnownZoneType(AuthZoneType t) =>
    t == AuthZoneType.Primary || t == AuthZoneType.Secondary || t == AuthZoneType.Stub ||
    t == AuthZoneType.Forwarder || t == AuthZoneType.Catalog || t == AuthZoneType.SecondaryCatalog;

Try / catch

try { zoneManager.CreateEmptyApexZone(zoneInfo); }
catch (InvalidDataException ex) when (ex.Message.Contains("zone type not supported"))
{
    // unknown/corrupt type — restore config or reject the request
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/d9f052ebdc8c096d. Report an issue: GitHub.

Appendix: source

Thrown at DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs:739

                case AuthZoneType.SecondaryForwarder:
                    apexZone = new SecondaryForwarderZone(_dnsServer, zoneInfo);
                    break;

                case AuthZoneType.Catalog:
                    apexZone = new CatalogZone(_dnsServer, zoneInfo);
                    break;

                case AuthZoneType.SecondaryCatalog:
                    SecondaryCatalogZone secondaryCatalogZone = new SecondaryCatalogZone(_dnsServer, zoneInfo);
                    secondaryCatalogZone.ZoneAdded += SecondaryCatalogZoneAdded;
                    secondaryCatalogZone.ZoneRemoved += SecondaryCatalogZoneRemoved;

                    apexZone = secondaryCatalogZone;
                    break;

                default:
                    throw new InvalidDataException("DNS zone type not supported.");
            }

            if (_root.TryAdd(apexZone))
                return apexZone;

            throw new DnsServerException("Zone already exists: " + zoneInfo.DisplayName);
        }

        internal AuthZone GetOrAddSubDomainZone(string zoneName, string domain)
        {
            return _root.GetOrAddSubDomainZone(zoneName, domain, delegate ()
            {
                if (!_root.TryGet(zoneName, out ApexZone apexZone))
                    throw new DnsServerException("Zone was not found for domain: " + domain);

                if (apexZone is PrimaryZone primaryZone)
                    return new PrimarySubDomainZone(primaryZone, domain);
                else if (apexZone is SecondaryCatalogZone secondaryCatalogZone)

View on GitHub (pinned to d0484b6c1e)