{"record":{"id":"827a3f8d492d3928","repo":"TechnitiumSoftware/DnsServer","slug":"statcounter-version-not-supported","errorCode":null,"errorMessage":"StatCounter version not supported.","messagePattern":"StatCounter version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Dns/StatsManager.cs","lineNumber":2059,"sourceCode":"                            _queries = new ConcurrentDictionary<DnsQuestionRecord, Counter>(1, count);\n\n                            for (int i = 0; i < count; i++)\n                                _queries.TryAdd(new DnsQuestionRecord(bR.BaseStream), new Counter(bR.ReadInt64()));\n                        }\n\n                        if (version <= 8)\n                        {\n                            int count = bR.ReadInt32();\n                            ConcurrentDictionary<IPAddress, Counter> errorIpAddresses = new ConcurrentDictionary<IPAddress, Counter>(1, count);\n\n                            for (int i = 0; i < count; i++)\n                                errorIpAddresses.TryAdd(IPAddressExtensions.ReadFrom(bR), new Counter(bR.ReadInt64()));\n                        }\n\n                        break;\n\n                    default:\n                        throw new InvalidDataException(\"StatCounter version not supported.\");\n                }\n\n                _locked = true;\n            }\n\n            #endregion\n\n            #region private\n\n            private static List<KeyValuePair<string, T>> GetTopList<T>(List<KeyValuePair<string, T>> list, int limit) where T : DashboardStats.TopStats\n            {\n                list.Sort(delegate (KeyValuePair<string, T> item1, KeyValuePair<string, T> item2)\n                {\n                    return item2.Value.Hits.CompareTo(item1.Value.Hits);\n                });\n\n                if (list.Count > limit)\n                    list.RemoveRange(limit, list.Count - limit);","sourceCodeStart":2041,"sourceCodeEnd":2077,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/StatsManager.cs#L2041-L2077","documentation":"Thrown by the StatCounter(BinaryReader) constructor when the version byte (after 'SC') is not in the handled set {1..9}. Each case migrates an older StatCounter layout (newer versions add fields like authoritative counts, response codes, EDNS, blocked stats, error IP addresses). The default rejects unrecognized versions to prevent buffer misalignment when reading the many counter fields.","triggerScenarios":"Reading a .stat file whose StatCounter version byte is outside the supported range, typically from a server newer than the running build, a truncated stream, or corruption of the version byte.","commonSituations":"Server downgrade across a StatCounter format bump; corrupt .stat file; stats folder shared between two server versions.","solutions":["Delete the offending .stat file; the period will be missing from historical stats.","Upgrade to the build that wrote the file, let it run so old files are superseded, then downgrade if needed.","Do not share a stats folder across server builds; use a fresh folder per version."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { counter = new StatCounter(bR); }\ncatch (InvalidDataException ex) when (ex.Message == \"StatCounter version not supported.\")\n{ counter = new StatCounter(); }","preventionTips":["Do not share a stats folder across server builds.","Upgrade to the build that wrote the file to drain old stats before downgrading."],"tags":["stats","stat-counter","version","serialization","deserialization"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}