{"record":{"id":"02dc3968b9719a5a","repo":"TechnitiumSoftware/DnsServer","slug":"lease-data-format-version-not-supported","errorCode":null,"errorMessage":"Lease data format version not supported.","messagePattern":"Lease data format version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Lease.cs","lineNumber":107,"sourceCode":"                    if (string.IsNullOrWhiteSpace(_hostName))\n                        _hostName = null;\n\n                    _hardwareAddress = bR.ReadBuffer();\n                    _address = IPAddressExtensions.ReadFrom(bR);\n\n                    if (version >= 2)\n                    {\n                        _comments = bR.BaseStream.ReadShortString();\n                        if (string.IsNullOrWhiteSpace(_comments))\n                            _comments = null;\n                    }\n\n                    _leaseObtained = bR.BaseStream.ReadDateTime();\n                    _leaseExpires = bR.BaseStream.ReadDateTime();\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"Lease data format version not supported.\");\n            }\n        }\n\n        #endregion\n\n        #region internal\n\n        internal static byte[] ParseHardwareAddress(string hardwareAddress)\n        {\n            string[] parts = hardwareAddress.Split(_hyphenColonSeparator);\n            byte[] address = new byte[parts.Length];\n\n            for (int i = 0; i < parts.Length; i++)\n                address[i] = byte.Parse(parts[i], NumberStyles.HexNumber, CultureInfo.InvariantCulture);\n\n            return address;\n        }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Lease.cs#L89-L125","documentation":"Deserializing a Lease from its binary stream hit a version byte the reader does not know (the switch default). The supported versions are handled in earlier cases; any other byte is rejected as unsupported.","triggerScenarios":"new Lease(BinaryReader) reads a version byte that is not one of the implemented case labels, throwing InvalidDataException from the default branch.","commonSituations":"Lease file written by a newer server version than the running binary. Corrupted/truncated lease file producing a garbage version byte. Downgrade across a format bump.","solutions":["Upgrade the DNS/DHCP server to a version that understands this lease format.","Discard/regenerate the affected lease file (leases will be re-acquired by clients).","Restore the lease file from a backup written by the same version."],"exampleFix":"// not a code fix: operational\n// before: running v6 reading a v8 lease file -> InvalidDataException\n// after: upgrade server binary to >= the version that wrote the file, or delete the lease file","handlingStrategy":"try-catch","validationCode":"// version is inside the binary stream; pre-check by peeking the version byte if you control the file\nbyte[] header = File.ReadAllBytes(path);\nif (header.Length < 2 || header[0] != (byte)'L') throw new InvalidDataException(\"Not a lease file\");\n// supported version set must match the running binary","typeGuard":"// no static type guard; format version is runtime data","tryCatchPattern":"try { var lease = new Lease(reader); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\"))\n{ /* upgrade server or drop the lease file */ }","preventionTips":["Keep server version >= the version that wrote the lease files.","Back up lease files before upgrading.","Treat unknown-version files as disposable (clients re-request)."],"tags":["dhcp","lease","serialization","versioning"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}