TechnitiumSoftware/DnsServer · error · InvalidOperationException

Cannot add record in Catalog zone.

Error message

Cannot add record in Catalog zone.

What it means

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.

Source

Thrown at DnsServerCore/Dns/Zones/CatalogZone.cs:424

                    DnsResourceRecord newSoaRecord = records[0];
                    DnsSOARecordData newSoa = newSoaRecord.RDATA as DnsSOARecordData;

                    //reset fixed record values
                    DnsSOARecordData modifiedSoa = new DnsSOARecordData("invalid", "invalid", newSoa.Serial, newSoa.Refresh, newSoa.Retry, newSoa.Expire, newSoa.Minimum);
                    DnsResourceRecord modifiedSoaRecord = new DnsResourceRecord(_name, DnsResourceRecordType.SOA, DnsClass.IN, 0, modifiedSoa) { Tag = newSoaRecord.Tag };

                    base.SetRecords(type, [modifiedSoaRecord]);
                    break;

                default:
                    throw new InvalidOperationException("Cannot set records in Catalog zone.");
            }

        }

        public override bool AddRecord(DnsResourceRecord record)
        {
            throw new InvalidOperationException("Cannot add record in Catalog zone.");
        }

        public override bool DeleteRecords(DnsResourceRecordType type)
        {
            throw new InvalidOperationException("Cannot delete record in Catalog zone.");
        }

        public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)
        {
            throw new InvalidOperationException("Cannot delete records in Catalog zone.");
        }

        public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)
        {
            throw new InvalidOperationException("Cannot update record in Catalog zone.");
        }

        public override IReadOnlyList<DnsResourceRecord> QueryRecords(DnsResourceRecordType type, bool dnssecOk)

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Do not call AddRecord on CatalogZone — use the dedicated member zone management APIs.
  2. Add a zone-type guard: if zone is CatalogZone, skip AddRecord and use AddMemberZone or equivalent.
  3. Use a PrimaryZone for any zone where you need to add individual records.

Example fix

// before
catalogZone.AddRecord(record);
// throws: Cannot add record in Catalog zone

// after
if (zone is CatalogZone catZone)
    catZone.AddMemberZone(memberDomain); // use catalog-specific API
else
    zone.AddRecord(record);
Defensive patterns

Strategy: type-guard

Validate before calling

if (zone is CatalogZone)
    throw new InvalidOperationException("AddRecord is not supported on Catalog zones. Use AddMemberZone instead.");
zone.AddRecord(record);

Type guard

static bool CanAddRecord(Zone zone) => zone is not CatalogZone;

Prevention

When it happens

Trigger: Calling AddRecord on a CatalogZone instance with any DnsResourceRecord. Reached through generic zone-management code that calls AddRecord without checking zone type.

Common situations: 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.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/bd9c096c39937fb5. Report an issue: GitHub.