{"record":{"id":"bd9c096c39937fb5","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-add-record-in-catalog-zone","errorCode":null,"errorMessage":"Cannot add record in Catalog zone.","messagePattern":"Cannot add record in Catalog zone\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/CatalogZone.cs","lineNumber":424,"sourceCode":"                    DnsResourceRecord newSoaRecord = records[0];\n                    DnsSOARecordData newSoa = newSoaRecord.RDATA as DnsSOARecordData;\n\n                    //reset fixed record values\n                    DnsSOARecordData modifiedSoa = new DnsSOARecordData(\"invalid\", \"invalid\", newSoa.Serial, newSoa.Refresh, newSoa.Retry, newSoa.Expire, newSoa.Minimum);\n                    DnsResourceRecord modifiedSoaRecord = new DnsResourceRecord(_name, DnsResourceRecordType.SOA, DnsClass.IN, 0, modifiedSoa) { Tag = newSoaRecord.Tag };\n\n                    base.SetRecords(type, [modifiedSoaRecord]);\n                    break;\n\n                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)","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/CatalogZone.cs#L406-L442","documentation":"CatalogZone.AddRecord unconditionally throws InvalidOperationException. Catalog zones (RFC 9432) are managed automatically — member zones are added/removed through the catalog's member-management mechanism (which writes PTR records under version labels), not through the standard AddRecord API. Individual record additions are not permitted because they would break the catalog zone's structured layout.","triggerScenarios":"Calling AddRecord on a CatalogZone instance with any DnsResourceRecord. Reached through generic zone-management code that calls AddRecord without checking zone type.","commonSituations":"Generic zone management APIs/UIs that don't differentiate zone types; scripts that iterate zones and add records uniformly; attempting to manually add PTR or other records to a catalog zone.","solutions":["Do not call AddRecord on CatalogZone — use the dedicated member zone management APIs.","Add a zone-type guard: if zone is CatalogZone, skip AddRecord and use AddMemberZone or equivalent.","Use a PrimaryZone for any zone where you need to add individual records."],"exampleFix":"// before\ncatalogZone.AddRecord(record);\n// throws: Cannot add record in Catalog zone\n\n// after\nif (zone is CatalogZone catZone)\n    catZone.AddMemberZone(memberDomain); // use catalog-specific API\nelse\n    zone.AddRecord(record);","handlingStrategy":"type-guard","validationCode":"if (zone is CatalogZone)\n    throw new InvalidOperationException(\"AddRecord is not supported on Catalog zones. Use AddMemberZone instead.\");\nzone.AddRecord(record);","typeGuard":"static bool CanAddRecord(Zone zone) => zone is not CatalogZone;","tryCatchPattern":null,"preventionTips":["Guard all AddRecord call sites with a CatalogZone type check.","Route catalog zone operations through dedicated member-management APIs.","In UI/API code, hide or disable record-add functionality for 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"}