{"record":{"id":"f79899d7f5e9bda2","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-delete-records-in-catalog-zone","errorCode":null,"errorMessage":"Cannot delete records in Catalog zone.","messagePattern":"Cannot delete records in Catalog zone\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/CatalogZone.cs","lineNumber":434,"sourceCode":"                default:\n                    throw new InvalidOperationException(\"Cannot set records in Catalog zone.\");\n            }\n\n        }\n\n        public override bool AddRecord(DnsResourceRecord record)\n        {\n            throw new InvalidOperationException(\"Cannot add record in Catalog zone.\");\n        }\n\n        public override bool DeleteRecords(DnsResourceRecordType type)\n        {\n            throw new InvalidOperationException(\"Cannot delete record in Catalog zone.\");\n        }\n\n        public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)\n        {\n            throw new InvalidOperationException(\"Cannot delete records in Catalog zone.\");\n        }\n\n        public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)\n        {\n            throw new InvalidOperationException(\"Cannot update record in Catalog zone.\");\n        }\n\n        public override IReadOnlyList<DnsResourceRecord> QueryRecords(DnsResourceRecordType type, bool dnssecOk)\n        {\n            if (type == DnsResourceRecordType.SOA)\n                return base.QueryRecords(type, dnssecOk); //allow SOA for zone transfer to work with bind\n\n            return []; //catalog zone is not queriable\n        }\n\n        #endregion\n\n        #region properties","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/CatalogZone.cs#L416-L452","documentation":"CatalogZone.DeleteRecord(type, rdata) unconditionally throws InvalidOperationException. Similar to DeleteRecords, individual record deletion is not permitted in catalog zones because the zone's records are managed through the member zone membership mechanism. Note the slight wording difference from 456 ('records' vs 'record') — this is the single-record delete path.","triggerScenarios":"Calling DeleteRecord(type, rdata) on a CatalogZone instance. Reached through generic record-management code that handles individual record deletion uniformly across zone types.","commonSituations":"DNS record management UI/API that provides per-record delete functionality; scripts that remove specific records; zone-transfer-based sync logic that deletes individual records.","solutions":["Do not call DeleteRecord on CatalogZone — manage catalog members via RemoveMemberZone.","Add a zone-type guard before the delete call.","Route catalog zone operations through catalog-specific management endpoints."],"exampleFix":"// before\ncatalogZone.DeleteRecord(DnsResourceRecordType.PTR, rdata);\n// throws: Cannot delete records in Catalog zone\n\n// after\nif (zone is CatalogZone catZone)\n    catZone.RemoveMemberZone(memberName);\nelse\n    zone.DeleteRecord(type, rdata);","handlingStrategy":"type-guard","validationCode":"if (zone is CatalogZone)\n    throw new InvalidOperationException(\"DeleteRecord is not supported on Catalog zones. Use RemoveMemberZone instead.\");\nzone.DeleteRecord(type, rdata);","typeGuard":"static bool CanDeleteRecord(Zone zone) => zone is not CatalogZone;","tryCatchPattern":null,"preventionTips":["Guard all DeleteRecord(type, rdata) call sites with a CatalogZone type check.","Route catalog zone record operations through member-management APIs.","In UI/API code, prevent single-record deletion on catalog zones."],"tags":["dns","catalog-zone","rfc-9432","read-only","api-misuse"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}