TechnitiumSoftware/DnsServer · error · InvalidOperationException
Cannot delete record in {} zone.
Error message
Cannot delete record in {} zone. What it means
Thrown unconditionally by SecondarySubDomainZone.DeleteRecord (single-record). Read-only secondary sub-domain zones reject local deletion with InvalidOperationException; the message uses the parent secondary zone's type name.
Source
Thrown at DnsServerCore/Dns/Zones/SecondarySubDomainZone.cs:58
}
#endregion
#region public
public override void SetRecords(DnsResourceRecordType type, IReadOnlyList<DnsResourceRecord> records)
{
throw new InvalidOperationException("Cannot set records in " + _secondaryZone.GetZoneTypeName() + " zone.");
}
public override bool AddRecord(DnsResourceRecord record)
{
throw new InvalidOperationException("Cannot add record in " + _secondaryZone.GetZoneTypeName() + " zone.");
}
public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)
{
throw new InvalidOperationException("Cannot delete record in " + _secondaryZone.GetZoneTypeName() + " zone.");
}
public override bool DeleteRecords(DnsResourceRecordType type)
{
throw new InvalidOperationException("Cannot delete records in " + _secondaryZone.GetZoneTypeName() + " zone.");
}
public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)
{
throw new InvalidOperationException("Cannot update record in " + _secondaryZone.GetZoneTypeName() + " zone.");
}
#endregion
}
}
View on GitHub (pinned to d0484b6c1e)
Solutions
- Check the zone is not a SecondarySubDomainZone before deleting.
- Convert to a primary sub-domain zone if deletions are needed.
- Wrap mutation calls in a helper that enforces writability.
Example fix
// before
zone.DeleteRecord(type, rdata);
// after
if (zone is SecondarySubDomainZone)
return; // read-only
zone.DeleteRecord(type, rdata); Defensive patterns
Strategy: type-guard
Validate before calling
if (zone is SecondarySubDomainZone)
return;
zone.DeleteRecord(type, rdata); Type guard
static bool IsWritable(AuthZone zone) => zone is not SecondarySubDomainZone;
Try / catch
null
Prevention
- Skip read-only zones in delete pipelines.
- Log skipped operations so silent no-ops are auditable.
When it happens
Trigger: Calling subZone.DeleteRecord(type, rdata) on a SecondarySubDomainZone.
Common situations: Generic delete pipelines that target all zones; cleanup routines that do not check writability.
Related errors
- Cannot delete records in {} zone.
- Cannot set records in {} zone.
- Cannot add record in {} zone.
- Cannot update record in {} zone.
- Cannot update DNS zone '{zoneInfo.DisplayName}': not a prima
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/4a11bcfaae04df99.
Report an issue: GitHub.