document.save corrupts complex Map fields of the document (with additionnal $*
keys)
#15196
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
8.9.5
Node.js version
22.13.1
MongoDB server version
8.0.4
Typescript version (if applicable)
No response
Description
After upgrading from mongoose 7.8.6 to mongoose 8.9.5, modifying a Map field containing an array corrupts the Map with invalid '$*' keys in the Map.
Once the Map is corrupted, it cannot be read or modified with mongoose anymore.
See example below to reproduce.
Note that we also quickly tested it with a mongoDB version 6 and 7; the problem is still the same. It seems to be only related to the version of mongoose.
Steps to Reproduce
In the example below. The field
test_map
if a map of an array of objects. It gets corrupted at step two of the code and we can observe this corruption at steps 3 and 4 of the code.Below is the resulting stdout (with mongoose 8.9.5):
Expected Behavior
Here is the correct stdout that is expected (generated with mongoose 7.8.6):
In particular, we see that after step 2 of the code, the object is corrupted in the DB with an additional '$*' key in the Map. Such a key is not valid and makes further access to the map with mongoose fail.
The text was updated successfully, but these errors were encountered: