{"record":{"id":"9d37b50be7dd0c1e","repo":"TechnitiumSoftware/DnsServer","slug":"the-record-type-is-not-supported-by-primary-zones-9d37b5","errorCode":null,"errorMessage":"The record type is not supported by primary zones.","messagePattern":"The record type is not supported by primary zones\\.","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/Zones/PrimaryZone.cs","lineNumber":2601,"sourceCode":"\n                            case AuthZoneDnssecStatus.SignedWithNSEC3:\n                                RefreshNSec3();\n                                break;\n                        }\n                    }\n\n                    TriggerNotify();\n                    break;\n\n                case DnsResourceRecordType.DNSKEY:\n                case DnsResourceRecordType.RRSIG:\n                case DnsResourceRecordType.NSEC:\n                case DnsResourceRecordType.NSEC3PARAM:\n                case DnsResourceRecordType.NSEC3:\n                    throw new InvalidOperationException(\"Cannot set DNSSEC records.\");\n\n                case DnsResourceRecordType.FWD:\n                    throw new DnsServerException(\"The record type is not supported by primary zones.\");\n\n                default:\n                    if (records[0].OriginalTtlValue > GetZoneSoaExpire())\n                        throw new DnsServerException(\"Cannot set records: TTL cannot be greater than SOA EXPIRE.\");\n\n                    if (!TrySetRecords(type, records, out IReadOnlyList<DnsResourceRecord> deletedRecords))\n                        throw new DnsServerException(\"Cannot set records. Please try again.\");\n\n                    CommitAndIncrementSerial(deletedRecords, records);\n\n                    if (_dnssecStatus != AuthZoneDnssecStatus.Unsigned)\n                        UpdateDnssecRecordsFor(this, type);\n\n                    TriggerNotify();\n                    break;\n            }\n        }\n","sourceCodeStart":2583,"sourceCodeEnd":2619,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Zones/PrimaryZone.cs#L2583-L2619","documentation":"Thrown by PrimaryZone.SetRecords() when the requested type is FWD. Forward records are a feature of forwarder/stub zones, not primary zones; a primary zone is authoritative and cannot contain forwarding directives, so the type is rejected.","triggerScenarios":"Calling SetRecords(DnsResourceRecordType.FWD, ...) on a primary zone.","commonSituations":"Generic zone-editing code that applies the same record set across zone types; importing a forwarder zone's FWD records into a primary zone; misidentifying a zone's type before editing.","solutions":["Do not set FWD records on a primary zone; FWD belongs only to forwarder zones.","Route FWD record management to the correct zone type (forwarder/stub zone).","Guard the call with a zone-type check or filter FWD from the input."],"exampleFix":"// before\nzone.SetRecords(DnsResourceRecordType.FWD, fwdRecords); // throws on primary zone\n\n// after\nif (zone.GetZoneTypeName() == \"Forwarder\")\n    zone.SetRecords(DnsResourceRecordType.FWD, fwdRecords);","handlingStrategy":"type-guard","validationCode":"if (type == DnsResourceRecordType.FWD && zone.GetZoneTypeName() == \"Primary\")\n    throw new ArgumentException(\"FWD records belong to forwarder zones, not primary zones.\");\n\nzone.SetRecords(type, records);","typeGuard":"static bool IsTypeSupportedByZone(DnsResourceRecordType t, Zone z) =>\n    !(t == DnsResourceRecordType.FWD && z.GetZoneTypeName() == \"Primary\");","tryCatchPattern":"try { zone.SetRecords(type, records); }\ncatch (DnsServerException ex) when (ex.Message == \"The record type is not supported by primary zones.\")\n{ Log.Error($\"{type} not supported on zone type '{zone.GetZoneTypeName()}'.\"); }","preventionTips":["Route FWD records only to forwarder/stub zones.","Check zone type before applying a record set.","Maintain per-zone-type allow-lists of record types."],"tags":["dns","record","fwd","forwarder","zone-management","validation"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}