You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Cannot assign an _id field a mongodb ObjectID value. Receive BSON version error. Code below produces:
> npx migrate-mongo up
ERROR: Could not migrate up 20230404223533-seed_accounts.js: Unsupported BSON version, bson types must be from bson 5.0 or later BSONVersionError: Unsupported BSON version, bson types must be from bson 5.0 or later
at serializeInto (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:3637:23)
at serializeObject (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:3199:22)
at serializeInto (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:3432:25)
at serializeObject (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:3199:22)
at serializeInto (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:3633:25)
at Object.serialize (~/.npm/_npx/d044f46583e57438/node_modules/bson/lib/bson.cjs:4015:32)
at Msg.serializeBson (~/.npm/_npx/d044f46583e57438/node_modules/mongodb/lib/cmap/commands.js:383:21)
at Msg.makeDocumentSegment (~/.npm/_npx/d044f46583e57438/node_modules/mongodb/lib/cmap/commands.js:377:37)
at Msg.toBin (~/.npm/_npx/d044f46583e57438/node_modules/mongodb/lib/cmap/commands.js:366:29)
at MessageStream.writeCommand (~/.npm/_npx/d044f46583e57438/node_modules/mongodb/lib/cmap/message_stream.js:43:34)
Describe the bug
Cannot assign an
_id
field a mongodb ObjectID value. Receive BSON version error. Code below produces:Likely source of the error thrown:
https://github.com/mongodb/js-bson/blob/2f5d919a11f7817ef1f03b3de7a0bde2182cb2b0/src/parser/serializer.ts#L713
To Reproduce
Using a valid ObjectID string value from MongoDB itself:
Removing the
_id
field gives us:Expected behavior
Should be able to provide a valid BSON string value and assign the _id directly.
Additional context
It used to work based on #119 (comment)
In the
mongosh
environment, I can do this:My local
npx
env reveals:The BSON version shown matches the major version required, so I do not understand the error.
My
package-lock.json
reveals:So perhaps this version mixing is the problem?
The text was updated successfully, but these errors were encountered: