{"record":{"id":"044e4a7525d95488","repo":"litedb-org/LiteDB","slug":"bson-type-not-supported","errorCode":null,"errorMessage":"BSON type not supported","messagePattern":"BSON type not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"LiteDB/Engine/Disk/Serializer/BufferReader.cs","lineNumber":555,"sourceCode":"            }\n            else if (type == 0x13) // Decimal\n            {\n                return this.ReadDecimal();\n            }\n            else if (type == 0xFF) // MinKey\n            {\n                return BsonValue.MinValue;\n            }\n            else if (type == 0x7F) // MaxKey\n            {\n                return BsonValue.MaxValue;\n            }\n            else if (type == 0x64) // Vector\n            {\n                return this.ReadVector();\n            }\n\n                throw new NotSupportedException(\"BSON type not supported\");\n        }\n\n        #endregion\n\n        public void Dispose()\n        {\n            _source?.Dispose();\n        }\n    }\n}","sourceCodeStart":537,"sourceCodeEnd":565,"githubUrl":"https://github.com/litedb-org/LiteDB/blob/f906a5f850678719e39a39a006cb66dcae563cfa/LiteDB/Engine/Disk/Serializer/BufferReader.cs#L537-L565","documentation":"Thrown by BufferReader.ReadValue when the BSON type byte read from a data stream does not match any known type code (0x01 Double, 0x02 String, 0x03 Document, 0x04 Array, 0x05 Binary, 0x07 ObjectId, 0x08 Boolean, 0x09 DateTime, 0x0A Null, 0x10 Int32, 0x12 Int64, 0x13 Decimal, 0x64 Vector, 0xFF MinKey, 0x7F MaxKey). This is a NotSupportedException, indicating a corrupt or foreign data stream. Note: the throw is unreachable in normal flow (dead code after the if-else chain), but fires if the type byte falls through.","triggerScenarios":"Reading a corrupted database file or a data file produced by an incompatible/other BSON library. A buffer position error causing misalignment of the type byte. Truncated or partially-written data pages.","commonSituations":"Database file corruption from improper shutdown, disk failure, or concurrent access by non-LiteDB tooling. Version mismatch where a newer BSON type code is read by an older LiteDB build. Manual tampering with the .db file.","solutions":["Restore the database from a known-good backup.","Verify the file was produced by a compatible LiteDB version; upgrade if reading a newer-format file.","Run the LiteDB repair/recovery tool if available for your version.","Ensure no external process is writing to the .db file concurrently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* read/parse from database file */ }\ncatch (NotSupportedException ex) when (ex.Message == \"BSON type not supported\")\n{ /* database corruption or version mismatch; restore backup or upgrade */ }","preventionTips":["Maintain backups of database files.","Ensure only one process writes to the .db file.","Verify LiteDB version compatibility when moving files between environments.","Avoid manual edits to .db files."],"tags":["engine","bson","deserialization","corruption","not-supported"],"backgroundTag":null,"analyzedSha":"f906a5f850678719e39a39a006cb66dcae563cfa","analyzedAt":"2026-08-13T21:56:30.148Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}