{"record":{"id":"3955e502b3f89186","repo":"TechnitiumSoftware/DnsServer","slug":"scope-data-format-version-not-supported","errorCode":null,"errorMessage":"Scope data format version not supported.","messagePattern":"Scope data format version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dhcp/Scope.cs","lineNumber":406,"sourceCode":"                        _ignoreClientIdentifierOption = false;\n\n                    {\n                        int count = bR.ReadInt32();\n                        if (count > 0)\n                        {\n                            for (int i = 0; i < count; i++)\n                            {\n                                Lease lease = new Lease(bR);\n\n                                _leases.TryAdd(lease.ClientIdentifier, lease);\n                            }\n                        }\n                    }\n\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"Scope data format version not supported.\");\n            }\n        }\n\n        #endregion\n\n        #region IDisposable\n\n        bool _disposed;\n\n        public void Dispose()\n        {\n            if (_disposed)\n                return;\n\n            _lastAddressOfferedLock?.Dispose();\n\n            _disposed = true;\n            GC.SuppressFinalize(this);","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dhcp/Scope.cs#L388-L424","documentation":"Scope(Stream) parsed the 'SC' header and version byte fine, but the version byte did not match any implemented case (1/2/3...), so the default branch throws InvalidDataException. The file is a scope file but from an incompatible version.","triggerScenarios":"Reading a scope file whose version byte is outside the supported case labels (e.g. written by a newer server).","commonSituations":"Server downgrade after an upgrade that bumped the scope format. Manually edited binary. Partial write leaving a bogus version.","solutions":["Upgrade the server to a version that supports this scope file version.","Recreate the scope manually and let the server write a fresh file.","Restore from a backup produced by the current version."],"exampleFix":"// operational\n// before: scope file version 4 read by a binary that only knows 1-3\n// after: upgrade server, or delete the scope file and recreate the scope","handlingStrategy":"try-catch","validationCode":"// peek version byte after the 'SC' magic and compare against supported set\nusing var fs = File.OpenRead(path);\nvar b = new byte[3];\nif (fs.Read(b, 0, 3) != 3 || b[0] != (byte)'S' || b[1] != (byte)'C') throw new InvalidDataException(\"bad scope file\");\n// int[] supported = new[]{1,2,3}; if (!supported.Contains(b[2])) throw new InvalidDataException(\"unsupported scope version\");","typeGuard":"// runtime data; guard via version check, not type narrowing","tryCatchPattern":"try { var scope = new Scope(stream, log, dhcpServer); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\"))\n{ /* upgrade server or recreate scope */ }","preventionTips":["Avoid downgrades across scope-format bumps.","Recreate scopes after a major version change.","Maintain backups compatible with the deployed version."],"tags":["dhcp","scope","serialization","versioning","corruption"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}