{"record":{"id":"e3f4d4a98ce36f90","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-update-record-in-catalog-zone","errorCode":null,"errorMessage":"Cannot update record in Catalog zone.","messagePattern":"Cannot update record in Catalog zone\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/CatalogZone.cs","lineNumber":439,"sourceCode":"\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\n\n        public override string CatalogZoneName\n        {\n            get { return base.CatalogZoneName; }\n            set { throw new InvalidOperationException(); }","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/CatalogZone.cs#L421-L457","documentation":"CatalogZone.UpdateRecord unconditionally throws InvalidOperationException. Record updates are not permitted in catalog zones because the zone content is structurally derived from member zone membership. Updating a record in place would violate the catalog zone's managed structure (RFC 9432). The only writable record is SOA, which is handled through SetRecords.","triggerScenarios":"Calling UpdateRecord(oldRecord, newRecord) on a CatalogZone instance. Reached through generic zone-management code that handles record edits uniformly.","commonSituations":"Zone management UI/API that provides record editing for all zone types; scripts that update records across multiple zones; zone-sync operations that attempt to update records in catalog zones.","solutions":["Do not call UpdateRecord on CatalogZone — for SOA changes use SetRecords(SOA, ...); for member changes use the catalog member-management APIs.","Add a zone-type check to route catalog zones away from UpdateRecord.","If the intent is to modify SOA timers, use SetRecords with the new SOA data."],"exampleFix":"// before\ncatalogZone.UpdateRecord(oldRecord, newRecord);\n// throws: Cannot update record in Catalog zone\n\n// after\nif (zone is CatalogZone catZone)\n{\n    if (newRecord.Type == DnsResourceRecordType.SOA)\n        catZone.SetRecords(DnsResourceRecordType.SOA, new[] { newRecord });\n    // else: not supported, skip or error\n}\nelse\n    zone.UpdateRecord(oldRecord, newRecord);","handlingStrategy":"type-guard","validationCode":"if (zone is CatalogZone)\n{\n    if (newRecord.Type == DnsResourceRecordType.SOA)\n        zone.SetRecords(DnsResourceRecordType.SOA, new[] { newRecord });\n    else\n        throw new InvalidOperationException(\"UpdateRecord is not supported on Catalog zones.\");\n}\nelse\n    zone.UpdateRecord(oldRecord, newRecord);","typeGuard":"static bool CanUpdateRecord(Zone zone) => zone is not CatalogZone;","tryCatchPattern":null,"preventionTips":["Guard all UpdateRecord call sites with a CatalogZone type check.","Route SOA updates through SetRecords for catalog zones.","Disable record-edit functionality for catalog zones in UI/API code."],"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-14T05:17:29.042Z"}