JosefNemec/Playnite · critical · NotSupportedException
BSON type not supported
Error message
BSON type not supported
What it means
Thrown as NotSupportedException by ReadElement in the V7 LiteDB file reader when it encounters a BSON type byte that is not one of the handled types (0x01 Double, 0x02 String, 0x03 Document, 0x04 Array, 0x05 Binary with subtype 0x00 or 0x04, 0x07 ObjectId, 0x08 Boolean, 0x09 DateTime, 0x0A Null, 0x10 Int32, 0x12 Int64, 0x13 Decimal, 0xFF MinKey, 0x7F MaxKey). This reader only migrates old LiteDB v4 (page format v7) databases, so unsupported types indicate either a corrupt file or a type that the migration reader was never designed to parse.
Source
Thrown at source/Playnite/Database/Collections/LiteDBFileReaderV7.cs:158
}
else if (type == 0x12) // Int64
{
return reader.ReadInt64();
}
else if (type == 0x13) // Decimal
{
return reader.ReadDecimal();
}
else if (type == 0xFF) // MinKey
{
return LiteDB.BsonValue.MinValue;
}
else if (type == 0x7F) // MaxKey
{
return LiteDB.BsonValue.MaxValue;
}
throw new NotSupportedException("BSON type not supported");
}
}
internal class ByteReader
{
private byte[] _buffer;
private int _length;
private int _pos;
public int Position { get { return _pos; } set { _pos = value; } }
public ByteReader(byte[] buffer)
{
_buffer = buffer;
_length = buffer.Length;
_pos = 0;
}
View on GitHub (pinned to 5911f4e964)
Solutions
- Identify the unsupported BSON type byte by adding logging before the throw to capture the raw type value.
- If the type is a valid BSON type not handled by the reader (e.g., 0x06 Undefined, 0x0B Regex, 0x0C DBPointer, 0x0D JavaScript, 0x0E Symbol, 0x0F JavaScriptWScope, 0x11 Timestamp), extend the reader to handle it or skip the element.
- If the database is corrupt, restore from a backup rather than forcing migration.
- Export data from the old Playnite version manually (CSV/JSON) and re-import into a fresh database instead of migrating the corrupt file.
- Check if the Playnite version that created the database is supported by the migration reader.
Example fix
// before — unsupported BSON type throws with no diagnostic info
throw new NotSupportedException("BSON type not supported");
// after — log the type byte and skip or handle unknown types
logger.Error($"Unsupported BSON type byte: 0x{type:X2} at position {reader.Position}");
if (type == 0x0B) // Regex
{
var pattern = reader.ReadCString();
var options = reader.ReadByte();
return LiteDB.BsonValue.Null; // or represent as string
}
throw new NotSupportedException($"BSON type 0x{type:X2} not supported"); Defensive patterns
Strategy: try-catch
Try / catch
try
{
var value = reader.ReadElement(byteReader, out string name);
}
catch (NotSupportedException ex) when (ex.Message.Contains("BSON type"))
{
logger.Error($"Corrupt or unsupported BSON type encountered during migration at position {byteReader.Position}. Aborting migration.");
throw new MigrationException("Database file contains unsupported BSON types and cannot be migrated.", ex);
} Prevention
- Back up the database before attempting migration.
- Log the raw type byte and stream position when this error occurs to diagnose the specific BSON type.
- If migrating from very old Playnite versions, test the migration on a copy first.
- Consider exporting data from the old version and re-importing if the file is corrupt.
When it happens
Trigger: Migrating an old Playnite database (LiteDB v4 / v7 format) that contains a BSON element with an unrecognized type byte. The binary type (0x05) with a subtype other than Generic (0x00) or Guid (0x04) also triggers this — the bytes are consumed but no value is returned, falling through to the throw.
Common situations: Attempting to migrate a database from an extremely old Playnite version that stored a data type the reader doesn't support. Database file corruption producing an invalid type byte. A third-party tool wrote to the LiteDB file with an unsupported BSON type. Manual editing of the database file.
Related errors
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/42069273ab6b62e0.
Report an issue: GitHub.