Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate seems to jump down to previous .dot level if value does not exist in Types.Mixed. #10191

Closed
EmilsWebbod opened this issue Apr 29, 2021 · 1 comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@EmilsWebbod
Copy link

Trying to upgrade one of my project to newest mongoose. its been a while since I had time on this.

I have a mixed Value in my Schema that looks like this:
image

And the I want to populate some values down the tree. params.value.optionLabels

OptionLabels.populate(category, {
  path: 'sections.products.params.value.optionLabels',
  select: '_id name',
  options: { lean: true }
})

In mongoose@5.10.2 this works fine and populates the optionLabels with _id and name from correct Model.

In mongoose@5.10.3 i get this error message

TypeError: Cannot create property 'optionLabels' on string 'asd'
    at lookupLocalFields (C:\Ludens\options\options-api\node_modules\mongoose\lib\helpers\populate\lookupLocalFields.js:13:15)
    at Object.exports.set (C:\Ludens\options\options-api\node_modules\mpath\lib\index.js:273:7)
    at Object.exports.set (C:\Ludens\options\options-api\node_modules\mpath\lib\index.js:222:19)
    at Object.exports.set (C:\Ludens\options\options-api\node_modules\mpath\lib\index.js:222:19)
    at Object.exports.set (C:\Ludens\options\options-api\node_modules\mpath\lib\index.js:222:19)
    at assignVals (C:\Ludens\options\options-api\node_modules\mongoose\lib\helpers\populate\assignVals.js:164:11)
    at _assign (C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4588:3)
    at _done (C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4437:7)
    at _next (C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4426:7)
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4504:5
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4838:16
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4861:21
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\query.js:4406:11
    at C:\Ludens\options\options-api\node_modules\kareem\index.js:135:16
    at processTicksAndRejections (internal/process/task_queues.js:79:11)
Emitted 'error' event on Function instance at:
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\model.js:4840:13
    at C:\Ludens\options\options-api\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
    [... lines matching original stack trace ...]
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

Looks like it try to create optionLabels to the 'asd' string (Image from DB end of post). Expected it to ignore this and move on to the next param items.

And this crashes my whole app, even if I have a try catch. Need to restart the server.

Added some images of how the content looks in my DB.
image
image

@IslandRhythms IslandRhythms added the needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue label May 4, 2021
@vkarpov15 vkarpov15 added this to the 5.12.8 milestone May 4, 2021
@vkarpov15 vkarpov15 added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue labels May 9, 2021
vkarpov15 added a commit that referenced this issue May 9, 2021
@vkarpov15
Copy link
Collaborator

Thanks for reporting, fix will be in v5.12.8 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

3 participants