{"record":{"id":"4402175f1c318e9a","repo":"TechnitiumSoftware/DnsServer","slug":"hourlystats-version-not-supported","errorCode":null,"errorMessage":"HourlyStats version not supported.","messagePattern":"HourlyStats version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Dns/StatsManager.cs","lineNumber":1763,"sourceCode":"                    throw new InvalidDataException(\"HourlyStats format is invalid.\");\n\n                byte version = bR.ReadByte();\n                switch (version)\n                {\n                    case 1:\n                        _hourStat = new StatCounter();\n                        _hourStat.Lock();\n\n                        for (int i = 0; i < _minuteStats.Length; i++)\n                        {\n                            _minuteStats[i] = new StatCounter(bR);\n                            _hourStat.Merge(_minuteStats[i]);\n                        }\n\n                        break;\n\n                    default:\n                        throw new InvalidDataException(\"HourlyStats version not supported.\");\n                }\n            }\n\n            #endregion\n\n            #region public\n\n            public void UpdateStat(DateTime dateTime, StatCounter minuteStat)\n            {\n                if (ReferenceEquals(this, Empty))\n                    return;\n\n                if (!minuteStat.IsLocked)\n                    throw new DnsServerException(\"StatCounter must be locked.\");\n\n                _hourStat.Merge(minuteStat);\n                _minuteStats[dateTime.Minute] = minuteStat;\n            }","sourceCodeStart":1745,"sourceCodeEnd":1781,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/StatsManager.cs#L1745-L1781","documentation":"Thrown by the HourlyStats(BinaryReader) constructor when the version byte (read after the 'HS' magic) is not 1. Only version 1 is supported; it reads 60 per-minute StatCounter entries and merges them into the hour total. The default rejects any other version so a future-format or corrupt file fails instead of being misread.","triggerScenarios":"Reading an hourly .stat file whose version byte is not 1, after the 'HS' magic passed. Caused by a file written by a newer build with a different HourlyStats layout, a truncated stream, or corruption of the version byte.","commonSituations":"Server downgrade across a HourlyStats version bump; corrupt .stat file; mixing stats files from different server versions in one stats folder.","solutions":["Delete the offending hourly .stat file; the hour will simply be missing from historical stats going forward.","If reproducing a downgrade, upgrade to the build that wrote the file to drain old stats, then downgrade.","Keep one stats folder per server build; do not share across versions."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { hourly = new HourlyStats(bR); }\ncatch (InvalidDataException ex) when (ex.Message == \"HourlyStats version not supported.\")\n{ hourly = HourlyStats.Empty; }","preventionTips":["Use a fresh stats folder per server build; do not share across versions.","Upgrade, let old files be superseded, then downgrade if needed."],"tags":["stats","hourly-stats","version","serialization","deserialization"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}