{"record":{"id":"24a44707a33b0e6e","repo":"TechnitiumSoftware/DnsServer","slug":"cluster-node-url-length-must-be-less-than-255-byte","errorCode":null,"errorMessage":"Cluster node URL length must be less than 255 bytes.","messagePattern":"Cluster node URL length must be less than 255 bytes\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Cluster/ClusterNode.cs","lineNumber":98,"sourceCode":"            _url = nodeInfo.Url;\n            _ipAddresses = nodeInfo.IPAddresses.Convert(IPAddress.Parse);\n            _type = Enum.Parse<ClusterNodeType>(nodeInfo.Type, true);\n\n            if (_type == ClusterNodeType.Primary)\n            {\n                _lastSeen = DateTime.UtcNow;\n                _state = ClusterNodeState.Connected; //since this info was received from primary node\n            }\n            else\n            {\n                _state = ClusterNodeState.Unknown;\n            }\n        }\n\n        public ClusterNode(ClusterManager clusterManager, int id, Uri url, IReadOnlyList<IPAddress> ipAddresses, ClusterNodeType type, ClusterNodeState state)\n        {\n            if (url.OriginalString.Length > 255)\n                throw new ArgumentException(\"Cluster node URL length must be less than 255 bytes.\", nameof(url));\n\n            if (!url.Scheme.Equals(\"https\", StringComparison.OrdinalIgnoreCase))\n                throw new ArgumentException(\"Cluster node URL must use HTTPS scheme.\", nameof(url));\n\n            if (ipAddresses.Count > 10)\n                throw new ArgumentException(\"Cluster node cannot have more than 10 IP addresses.\", nameof(ipAddresses));\n\n            _clusterManager = clusterManager;\n\n            _id = id;\n            _url = url;\n            _ipAddresses = ipAddresses;\n            _type = type;\n            _state = state;\n        }\n\n        public ClusterNode(ClusterManager clusterManager, BinaryReader bR)\n        {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Cluster/ClusterNode.cs#L80-L116","documentation":"Constructor argument guard on the explicit ClusterNode(ClusterManager, int, Uri, IReadOnlyList<IPAddress>, ...) overload. It rejects a URL whose originalString exceeds 255 characters. The 255 cap exists because ClusterNode.WriteTo() serializes the URL via BinaryWriter.WriteShortString(), which uses a single-byte length prefix (max 255 bytes), so a longer URL would corrupt the on-disk cluster config. Note the check is '> 255', so values 0..255 are accepted even though the message says 'less than 255'.","triggerScenarios":"Calling the 5-parameter ClusterNode constructor with a Uri whose originalString is 256+ characters — e.g. an extremely long FQDN, an unusual port, or a URL carrying a long path/query suffix.","commonSituations":"A very long fully-qualified domain name used as the cluster node URL; accidentally appending a path or query string to the node URL; copy-paste of a full management-UI URL instead of the bare https://host:port/ form.","solutions":["Shorten the node's domain name so the full https://host:port/ URL stays within 255 characters.","Strip any path/query/fragment from the URL before constructing the node (cluster node URLs are root paths).","If you control the host naming, use a shorter subdomain or drop unnecessary labels.","Validate url.OriginalString.Length before instantiating ClusterNode."],"exampleFix":"// before\nvar url = new Uri(\"https://really-long-hostname-with-many-labels.example.com:5380/some/long/path?x=1\");\nvar node = new ClusterNode(mgr, id, url, ips, type, state); // throws [201]\n\n// after: bare root URL, short host\nvar url = new Uri(\"https://ns1.example.com:5380/\");\nif (url.OriginalString.Length > 255) throw new InvalidOperationException(\"URL too long\");\nvar node = new ClusterNode(mgr, id, url, ips, type, state);","handlingStrategy":"validation","validationCode":"static void ValidateClusterNodeUrl(Uri url)\n{\n    ArgumentNullException.ThrowIfNull(url);\n    if (url.OriginalString.Length > 255)\n        throw new ArgumentException(\"Cluster node URL must be <= 255 chars.\", nameof(url));\n}\n\nValidateClusterNodeUrl(url);\nvar node = new ClusterNode(mgr, id, url, ips, type, state);","typeGuard":"static bool IsValidClusterNodeUrl(Uri url) =>\n    url is not null && url.OriginalString.Length <= 255;","tryCatchPattern":null,"preventionTips":["Use bare root URLs (https://host:port/) for cluster nodes — no paths or query strings.","Keep hostnames short.","Validate URL length before constructing ClusterNode."],"tags":["cluster","validation","constructor","serialization","url-length"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}