{"record":{"id":"2bbf5836c7d972b9","repo":"TechnitiumSoftware/DnsServer","slug":"invalid-data-or-version-not-supported","errorCode":null,"errorMessage":"Invalid data or version not supported.","messagePattern":"Invalid data or version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"critical","filePath":"DnsServerCore/Auth/UserSession.cs","lineNumber":102,"sourceCode":"                    _type = (UserSessionType)bR.ReadByte();\n\n                    _tokenName = bR.BaseStream.ReadShortString();\n                    if (_tokenName.Length == 0)\n                        _tokenName = null;\n\n                    users.TryGetValue(bR.BaseStream.ReadShortString().ToLowerInvariant(), out _user);\n\n                    _lastSeen = bR.BaseStream.ReadDateTime();\n                    _lastSeenRemoteAddress = IPAddressExtensions.ReadFrom(bR);\n\n                    _lastSeenUserAgent = bR.BaseStream.ReadShortString();\n                    if (_lastSeenUserAgent.Length == 0)\n                        _lastSeenUserAgent = null;\n\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"Invalid data or version not supported.\");\n            }\n        }\n\n        #endregion\n\n        #region public\n\n        public void UpdateUserObject(IReadOnlyDictionary<string, User> users)\n        {\n            if (users.TryGetValue(_user.Username, out User user))\n                _user = user;\n        }\n\n        public void UpdateLastSeen(IPAddress remoteAddress, string lastSeenUserAgent)\n        {\n            if (remoteAddress.IsIPv4MappedToIPv6)\n                remoteAddress = remoteAddress.MapToIPv4();\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Auth/UserSession.cs#L84-L120","documentation":"Thrown by the UserSession(BinaryReader, users) deserialization constructor when the leading version byte is not 1. This means the persisted session data is either from a newer server version that this build does not understand, or the byte stream is corrupt/truncated so the version read is garbage. InvalidDataException is used because the stream content is the problem, not the call.","triggerScenarios":"Loading a users.config/sessions file that was written by a newer Technitium build (version byte > 1), or a file that was partially written, truncated, or byte-corrupted so the version field reads as an unexpected value.","commonSituations":"Downgrading the DNS server to an older version after sessions were saved by a newer one; a crashed/aborted save leaving a truncated config; manual edits or disk corruption of the config file.","solutions":["Restore the config file from backup if it is corrupt.","Upgrade (not downgrade) the DNS server so the version byte is recognized, or delete the session store to force a fresh login.","Verify file integrity (size, header) before handing the stream to the constructor."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var session = new UserSession(bR, users);\n}\ncatch (InvalidDataException ex) when (ex.Message == \"Invalid data or version not supported.\")\n{\n    logger.LogError(ex, \"Session store version/byte unsupported; recreating sessions.\");\n    // fall back to fresh session store, forcing re-login\n}","preventionTips":["Back up the session/user config files before upgrades.","Do not downgrade the server below the version that wrote the files.","Validate file header/version bytes before deserializing."],"tags":["auth","session","serialization","version","corruption","technitium-dns-server"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}