{"record":{"id":"4b008b4b58a7aeec","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-set-records-in-catalog-zone","errorCode":null,"errorMessage":"Cannot set records in Catalog zone.","messagePattern":"Cannot set records in Catalog zone\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/CatalogZone.cs","lineNumber":417,"sourceCode":"        {\n            switch (type)\n            {\n                case DnsResourceRecordType.SOA:\n                    if ((records.Count != 1) || !records[0].Name.Equals(_name, StringComparison.OrdinalIgnoreCase))\n                        throw new InvalidOperationException(\"Invalid SOA record.\");\n\n                    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        }","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/CatalogZone.cs#L399-L435","documentation":"CatalogZone.SetRecords only accepts SOA records (for zone transfer compatibility with BIND). The default case throws InvalidOperationException for all other record types. Catalog zones (RFC 9432) are special-purpose zones whose contents are managed automatically through member zone membership — they are not general-purpose zones where arbitrary records can be set. Only the fixed SOA is writable.","triggerScenarios":"Calling SetRecords on a CatalogZone with any record type other than SOA (A, AAAA, MX, TXT, NS, PTR, etc.). Reached through generic zone-management code or API handlers that don't check the zone type before calling SetRecords.","commonSituations":"Zone management UI/API that applies the same SetRecords path to all zone types; scripts that blindly push records to all zones; attempting to manually add custom records to a catalog zone; zone import tools that don't filter by zone type.","solutions":["Do not attempt to set non-SOA records on a CatalogZone — use a PrimaryZone or SecondaryZone for general records.","Add a zone-type check in calling code: skip or reject record operations on CatalogZone unless type is SOA.","For member zone management, use the dedicated CatalogZone member-management APIs (AddMemberZone, RemoveMemberZone) instead of SetRecords."],"exampleFix":"// before\ncatalogZone.SetRecords(DnsResourceRecordType.A, aRecords);\n// throws: Cannot set records in Catalog zone\n\n// after\nif (catalogZone.GetZoneTypeName() == \"Catalog\" && type != DnsResourceRecordType.SOA)\n    throw new InvalidOperationException(\"Catalog zones only support SOA records.\");\n// use a PrimaryZone for A records instead","handlingStrategy":"type-guard","validationCode":"if (zone is CatalogZone && type != DnsResourceRecordType.SOA)\n    throw new InvalidOperationException(\"Catalog zones only support SOA records via SetRecords.\");\nzone.SetRecords(type, records);","typeGuard":"static bool CanSetRecords(Zone zone, DnsResourceRecordType type)\n    => !(zone is CatalogZone) || type == DnsResourceRecordType.SOA;","tryCatchPattern":null,"preventionTips":["Check zone type before calling SetRecords — catalog zones only accept SOA.","Use catalog-specific member-management APIs for catalog zone content.","Build zone-type-aware dispatch in generic zone-management 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-14T00:17:13.853Z"}