{"record":{"id":"6ff6981b94037e65","repo":"TechnitiumSoftware/DnsServer","slug":"invalid-soa-record","errorCode":null,"errorMessage":"Invalid SOA record.","messagePattern":"Invalid SOA record\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/CatalogZone.cs","lineNumber":404,"sourceCode":"            throw new DnsServerException(\"Failed to generate unique label for the given domain name '\" + domain + \"'. Please try again.\");\n        }\n\n        #endregion\n\n        #region public\n\n        public override string GetZoneTypeName()\n        {\n            return \"Catalog\";\n        }\n\n        public override void SetRecords(DnsResourceRecordType type, IReadOnlyList<DnsResourceRecord> records)\n        {\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)","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/CatalogZone.cs#L386-L422","documentation":"CatalogZone.SetRecords for SOA validates that exactly one SOA record is provided and that its owner name matches the catalog zone's own name (_name). If records.Count != 1 or the record name does not match, it throws InvalidOperationException. Catalog zones have a fixed SOA with specific mandated values; the method also overwrites MNAME and RNAME with 'invalid' per RFC 9432, keeping only serial/timer values from the input.","triggerScenarios":"Calling SetRecords(DnsResourceRecordType.SOA, records) on a CatalogZone where records has zero, two, or more entries, or where the record's Name property doesn't equal the catalog zone name. Also fires if the RDATA is not castable to DnsSOARecordData (would NPE on the cast, but the count/name check fires first).","commonSituations":"Zone transfer logic importing SOA records from a primary catalog server where the record name doesn't match; sending an empty or multi-record SOA list; programmatically building SOA records with the wrong owner name; BIND-style zone files where SOA name differs.","solutions":["Ensure exactly one SOA record is passed with its Name equal to the catalog zone name.","If importing via zone transfer, normalize the SOA record name to the local zone name before calling SetRecords.","Validate: records.Count == 1 && records[0].Name.Equals(catalogZone.Name, StringComparison.OrdinalIgnoreCase) before the call."],"exampleFix":"// before\ncatalogZone.SetRecords(DnsResourceRecordType.SOA, soaRecords);\n// throws if soaRecords.Count != 1 or name mismatch\n\n// after\nvar soa = new DnsResourceRecord(\n    catalogZone.Name, // must match zone name\n    DnsResourceRecordType.SOA,\n    DnsClass.IN, 0, soaData);\ncatalogZone.SetRecords(DnsResourceRecordType.SOA, new[] { soa });","handlingStrategy":"validation","validationCode":"if (records.Count != 1)\n    throw new ArgumentException(\"Catalog zone SOA requires exactly one record.\");\nif (!records[0].Name.Equals(catalogZone.Name, StringComparison.OrdinalIgnoreCase))\n    throw new ArgumentException($\"SOA record name '{records[0].Name}' must match catalog zone name '{catalogZone.Name}'.\");\ncatalogZone.SetRecords(DnsResourceRecordType.SOA, records);","typeGuard":"static bool IsValidCatalogSoa(IReadOnlyList<DnsResourceRecord> records, string zoneName)\n    => records.Count == 1\n    && records[0].Name.Equals(zoneName, StringComparison.OrdinalIgnoreCase)\n    && records[0].RDATA is DnsSOARecordData;","tryCatchPattern":null,"preventionTips":["Validate SOA record count (exactly 1) and owner name (equals zone name) before calling SetRecords on a catalog zone.","Normalize SOA record names during zone transfer import to match the local zone name.","Test with known-good SOA data when developing catalog zone integrations."],"tags":["dns","catalog-zone","soa","rfc-9432","validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}