[Bug] reserved schema keys don't throw when type is nested object #8869
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Passing the Schema constructor an object with the key
errors
causes a very obscure, non-obvious error to be thrown only once an associated Document issave()
d orcreate()
d, producing an error about priorDoc being undefined:If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Ideally, the user should see an error indicating that a restricted keyword was used, or indicate some issue in the Schema constructor. It was very hard to track down the underlying issue in the current format. Searching docs and even google for
priorDoc
undefined yields nothing useful. After scouring the docs I noticedprototype.errors
being some sort of reserved keyword.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Mongoose 5.9.10
NodeJS 12.16.1
MongoDB 4.2.6
The text was updated successfully, but these errors were encountered: