agent-nodejs icon indicating copy to clipboard operation
agent-nodejs copied to clipboard

fix(datasource-mongoose): handle ObjectId with _bsontype in replaceMongoTypes

Open Scra3 opened this issue 1 month ago • 1 comments

…ngoTypes

Sometimes MongoDB driver returns ObjectId instances that don't pass instanceof Types.ObjectId checks due to different BSON module versions being loaded. These objects have a _bsontype: 'ObjectId' property.

This fix adds a fallback check for _bsontype === 'ObjectId' to ensure ObjectIds are always converted to hex strings, preventing flaky test failures where _id is returned as a raw buffer instead of a string.

🤖 Generated with Claude Code

Definition of Done

General

  • [ ] Write an explicit title for the Pull Request, following Conventional Commits specification
  • [ ] Test manually the implemented changes
  • [ ] Validate the code quality (indentation, syntax, style, simplicity, readability)

Security

  • [ ] Consider the security impact of the changes made

Scra3 avatar Jan 06 '26 13:01 Scra3