TechnitiumSoftware/DnsServer · error · InvalidDataException
Failed to load DNS zone file: the zone file does not contain
Error message
Failed to load DNS zone file: the zone file does not contain any records.
What it means
Thrown by AuthZoneManager.LoadZoneFrom in zone-file version 4 (the current format, which serializes AuthZoneInfo and per-record auth info) when the record count read from the stream is less than 1. Version 4 stores the zone info separately and then the record array, so a zero record array is rejected immediately before parsing.
Source
Thrown at DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs:548
return zoneInfo;
}
case 4:
{
//read zone info
AuthZoneInfo zoneInfo = new AuthZoneInfo(bR, lastModified);
//create zone
ApexZone apexZone = CreateEmptyApexZone(zoneInfo);
zoneInfo = new AuthZoneInfo(apexZone);
try
{
//read all zone records
DnsResourceRecord[] records = new DnsResourceRecord[bR.ReadInt32()];
if (records.Length < 1)
throw new InvalidDataException("Failed to load DNS zone file: the zone file does not contain any records.");
for (int i = 0; i < records.Length; i++)
{
records[i] = new DnsResourceRecord(s);
records[i].Tag = AuthRecordInfo.ReadGenericRecordInfoFrom(bR, records[i].Type);
}
//load and init zone
LoadAndInitZone(zoneInfo, records);
}
catch
{
DeleteZone(zoneInfo);
throw;
}
return zoneInfo;
}View on GitHub (pinned to d0484b6c1e)
Solutions
- Restore from backup or re-create/re-transfer the zone.
- Make the writer refuse to persist a zone with zero records, and write atomically (temp + rename).
- Validate the record count before invoking LoadZoneFrom.
Defensive patterns
Strategy: validation
Validate before calling
bool ZoneV4HasRecords(string path)
{
using var fs = File.OpenRead(path);
using var br = new BinaryReader(fs);
if (Encoding.ASCII.GetString(br.ReadBytes(2)) != "DZ") return false;
if (br.ReadByte() != 4) return false;
// AuthZoneInfo header length is variable; this check is best done after a full header parse
return true;
} Try / catch
try { zoneManager.LoadZoneFrom(fs, lastModified); }
catch (InvalidDataException ex) when (ex.Message.Contains("does not contain any records"))
{
// v4 zero records — restore backup or re-create/re-transfer
} Prevention
- Refuse to persist a zone with zero records.
- Write zone files atomically (temp + rename).
- Keep backups and validate record counts before loading.
When it happens
Trigger: Loading a version-4 zone file whose record-count integer is 0 — empty record list following a valid AuthZoneInfo header.
Common situations: A zone saved before any records existed, a truncated/partial write of the record section, or a corrupt count field.
Related errors
- DnsServer zone file format is invalid.
- Zone does not contain SOA record.
- DnsServer allowed zone file format is invalid.
- DNS Zone file version not supported.
- The domain name '<domain>' does not belong to the zone: <zon
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/42e0be8b4bcd4fba.
Report an issue: GitHub.