{"record":{"id":"0564467433820eb4","repo":"TechnitiumSoftware/DnsServer","slug":"no-such-zone-was-found-zonename","errorCode":null,"errorMessage":"No such zone was found: {zoneName}","messagePattern":"No such zone was found: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":2698,"sourceCode":"            apexZone.UpdateDnssecStatus();\n\n            SaveZoneFile(apexZone.Name);\n        }\n\n        public IReadOnlyList<DnsResourceRecord> SyncIncrementalZoneTransferRecords(string zoneName, IReadOnlyList<DnsResourceRecord> xfrRecords)\n        {\n            if ((xfrRecords.Count < 2) || (xfrRecords[0].Type != DnsResourceRecordType.SOA) || !xfrRecords[0].Name.Equals(zoneName, StringComparison.OrdinalIgnoreCase) || !xfrRecords[xfrRecords.Count - 1].Equals(xfrRecords[0]))\n                throw new DnsServerException(\"Invalid IXFR/AXFR response was received.\");\n\n            if ((xfrRecords.Count < 4) || (xfrRecords[1].Type != DnsResourceRecordType.SOA))\n            {\n                //received AXFR response\n                SyncZoneTransferRecords(zoneName, xfrRecords);\n                return Array.Empty<DnsResourceRecord>();\n            }\n\n            if (!_root.TryGet(zoneName, out ApexZone apexZone))\n                throw new InvalidOperationException(\"No such zone was found: \" + zoneName);\n\n            IReadOnlyList<DnsResourceRecord> soaRecords = apexZone.GetRecords(DnsResourceRecordType.SOA);\n            if (soaRecords.Count != 1)\n                throw new InvalidOperationException(\"No authoritative zone was found: \" + zoneName);\n\n            //process IXFR response\n            DnsResourceRecord currentSoaRecord = soaRecords[0];\n            DnsSOARecordData currentSoa = currentSoaRecord.RDATA as DnsSOARecordData;\n\n            List<DnsResourceRecord> condensedXfrRecords = CondenseIncrementalZoneTransferRecords(zoneName, currentSoaRecord, xfrRecords);\n\n            List<DnsResourceRecord> deletedRecords = new List<DnsResourceRecord>();\n            List<DnsResourceRecord> deletedGlueRecords = new List<DnsResourceRecord>();\n            List<DnsResourceRecord> addedRecords = new List<DnsResourceRecord>();\n            List<DnsResourceRecord> addedGlueRecords = new List<DnsResourceRecord>();\n\n            //read and apply difference sequences\n            int index = 1;","sourceCodeStart":2680,"sourceCodeEnd":2716,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L2680-L2716","documentation":"Thrown by SyncIncrementalZoneTransferRecords when the IXFR response passes envelope validation but _root.TryGet(zoneName, out ApexZone) fails. This means the zone was removed from the local tree between the transfer request and the sync call. It is an InvalidOperationException with the zone name in the message.","triggerScenarios":"Calling SyncIncrementalZoneTransferRecords where the zone no longer exists in _root. The xfrRecords passed validation (valid SOA envelope), and the response is determined to be IXFR format (count >= 4, second record is SOA). The zone was deleted (by admin or automation) in the time window between fetching the transfer data and calling sync.","commonSituations":"Race condition: zone deleted by another admin/thread while IXFR data is in transit; automated zone lifecycle that deletes and recreates zones; zone file removed from disk and server reloaded during transfer; transfer retry arriving after zone removal.","solutions":["Check _root.TryGet or GetAuthZoneInfo before calling SyncIncrementalZoneTransferRecords to confirm the zone still exists.","If the zone was intentionally deleted, discard the transfer data gracefully.","Implement zone-level locking to prevent deletion during active transfers.","Log the condition and alert if unexpected."],"exampleFix":"// before\nvar deleted = authZoneManager.SyncIncrementalZoneTransferRecords(zoneName, xfrRecords);\n\n// after\nif (authZoneManager.GetAuthZoneInfo(zoneName) is null)\n{\n    _logger.LogWarning(\"Zone '{Zone}' was removed during IXFR; discarding transfer data.\", zoneName);\n    return Array.Empty<DnsResourceRecord>();\n}\nvar deleted = authZoneManager.SyncIncrementalZoneTransferRecords(zoneName, xfrRecords);","handlingStrategy":"validation","validationCode":"if (authZoneManager.GetAuthZoneInfo(zoneName) is null)\n{\n    logger.LogWarning(\"Zone '{Zone}' was removed during IXFR; discarding transfer data.\", zoneName);\n    return Array.Empty<DnsResourceRecord>();\n}","typeGuard":"static bool ZoneStillExists(AuthZoneManager mgr, string zoneName)\n    => mgr.GetAuthZoneInfo(zoneName) is not null;","tryCatchPattern":"try\n{\n    var deleted = authZoneManager.SyncIncrementalZoneTransferRecords(zoneName, xfrRecords);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"No such zone was found\"))\n{\n    logger.LogInformation(\"IXFR sync skipped: zone '{Zone}' was removed.\", zoneName);\n}","preventionTips":["Re-check zone existence immediately before syncing incremental transfer data.","Implement zone-level locking to prevent deletion during active transfers.","Treat zone removal during transfer as a graceful no-op."],"tags":["zone-transfer","ixfr","zone-management","race-condition","validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}