22 — InvalidBSON

ValidationErrorConnectionFatalMessageParseError

Invalid BSON — MongoDB error code 22

Source code references

ErrorCodes::InvalidBSON found in 35 locations in the MongoDB server source.

Detailed investigation data (common causes, diagnostic steps) is not yet available for this error code. The information above comes from the official MongoDB error code reference.

Related Issues

SERVER-139135Closed
getESERotateActiveKEKStatus reports Date_t::min() rotation times after restart
After a restart, {{getESERotateActiveKEKStatus}} reports the persisted active KEK as {{completed}} with {{lastStartRotationTime}}/{{lastEndRotationTime}} set to {{Date\_t::min\(\)}}, because no rotation has run on the node yet. pymongo cannot decode that date \({{InvalidBSON: year 292278994 is out of range}}\), which breaks the {{ContinuousESERotation}} hook. Fix: omit each time field until this node has run a rotation.
PYTHON-6163Closed
Pure-Python decode_all silently accepts 1-byte invalid BSON
h3. Detailed steps to reproduce the problem? {{bson.decode_all()}} disagrees between the C extension and the pure-Python implementation for a 1-byte input. The C extension raises {{InvalidBSON}}. The pure-Python implementation returns {{[]}}. h3. Definition of done: what must be done to consider the task complete? - The pure-Python implementation raises {{InvalidBSON}} for a 1-byte buffer, matching the C extension. Empty input ({{b""}}) must still return {{[]}}. - Pytest regress
PYTHON-6172Closed
C/pure-Python decoders disagree on short UUID payloads
h3. Detailed steps to reproduce the problem? Found by the PYTHON-4232 BSON fuzzer; the Evergreen fuzz task failed with: https://spruce.corp.mongodb.com/task/mongo_python_driver_fuzz_rhel8_fuzz_patch_e0b11bf246f9668ae2ed9be7703ebb8b4d862b7e_6acf7861d0463e000733a876_26_10_14_12_41_14/logs?execution=0 Reproducing locally: With the C extension present this raises {{InvalidBSON: invalid length or type code}}. With {{bson._cbson}} blocked it returns {{[{'': Binary(b'', 4)}]}}. T