{"record":{"id":"fd135a305669f215","repo":"TechnitiumSoftware/DnsServer","slug":"cannot-update-record-in-zone","errorCode":null,"errorMessage":"Cannot update record in {} zone.","messagePattern":"Cannot update record in (.+?) zone\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/SecondarySubDomainZone.cs","lineNumber":68,"sourceCode":"\n        public override bool AddRecord(DnsResourceRecord record)\n        {\n            throw new InvalidOperationException(\"Cannot add record in \" + _secondaryZone.GetZoneTypeName() + \" zone.\");\n        }\n\n        public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)\n        {\n            throw new InvalidOperationException(\"Cannot delete record in \" + _secondaryZone.GetZoneTypeName() + \" zone.\");\n        }\n\n        public override bool DeleteRecords(DnsResourceRecordType type)\n        {\n            throw new InvalidOperationException(\"Cannot delete records in \" + _secondaryZone.GetZoneTypeName() + \" zone.\");\n        }\n\n        public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)\n        {\n            throw new InvalidOperationException(\"Cannot update record in \" + _secondaryZone.GetZoneTypeName() + \" zone.\");\n        }\n\n        #endregion\n    }\n}\n","sourceCodeStart":50,"sourceCodeEnd":74,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/SecondarySubDomainZone.cs#L50-L74","documentation":"Thrown unconditionally by SecondarySubDomainZone.UpdateRecord. Read-only secondary sub-domain zones cannot be updated locally; InvalidOperationException is thrown with the parent zone's type name embedded. Completes the set of rejected mutations (set/add/delete/deleteRecords/update).","triggerScenarios":"Calling subZone.UpdateRecord(oldRecord, newRecord) on a SecondarySubDomainZone.","commonSituations":"Record editors that call UpdateRecord across all zones; change-replay tooling that does not distinguish read-only sub-domains.","solutions":["Detect SecondarySubDomainZone and skip UpdateRecord.","Switch to a primary sub-domain zone to enable updates.","Guard all record-mutation entry points with a writability check."],"exampleFix":"// before\nzone.UpdateRecord(oldRecord, newRecord);\n\n// after\nif (zone is SecondarySubDomainZone)\n    return; // read-only\nzone.UpdateRecord(oldRecord, newRecord);","handlingStrategy":"type-guard","validationCode":"if (zone is SecondarySubDomainZone)\n    return;\nzone.UpdateRecord(oldRecord, newRecord);","typeGuard":"static bool IsWritable(AuthZone zone) => zone is not SecondarySubDomainZone;","tryCatchPattern":"null","preventionTips":["Wrap update entry points with a writability guard.","Use a primary sub-domain zone to enable record updates."],"tags":["dns","secondary-subdomain-zone","read-only","immutable","zone-type","update"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}