TechnitiumSoftware/DnsServer · error · InvalidOperationException

Cannot delete records in Catalog zone.

Error message

Cannot delete records in Catalog zone.

What it means

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.

Source

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

                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)
        {
            if (type == DnsResourceRecordType.SOA)
                return base.QueryRecords(type, dnssecOk); //allow SOA for zone transfer to work with bind

            return []; //catalog zone is not queriable
        }

        #endregion

        #region properties

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Do not call DeleteRecord on CatalogZone — manage catalog members via RemoveMemberZone.
  2. Add a zone-type guard before the delete call.
  3. Route catalog zone operations through catalog-specific management endpoints.

Example fix

// before
catalogZone.DeleteRecord(DnsResourceRecordType.PTR, rdata);
// throws: Cannot delete records in Catalog zone

// after
if (zone is CatalogZone catZone)
    catZone.RemoveMemberZone(memberName);
else
    zone.DeleteRecord(type, rdata);
Defensive patterns

Strategy: type-guard

Validate before calling

if (zone is CatalogZone)
    throw new InvalidOperationException("DeleteRecord is not supported on Catalog zones. Use RemoveMemberZone instead.");
zone.DeleteRecord(type, rdata);

Type guard

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

Prevention

When it happens

Trigger: Calling DeleteRecord(type, rdata) on a CatalogZone instance. Reached through generic record-management code that handles individual record deletion uniformly across zone types.

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

Related errors


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