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

Push to document array fails #8312

Closed
avichaishapira1 opened this issue Nov 7, 2019 · 5 comments
Closed

Push to document array fails #8312

avichaishapira1 opened this issue Nov 7, 2019 · 5 comments
Milestone

Comments

@avichaishapira1
Copy link

This behavior exists in version 5.7.8
This behavior does not exist in version 5.6.9

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

story is a complex document with many subdocuments and subdocuments arrays
let obj = story.segmentation // this is a subdocument array
let segmentation = {
// json object contains fields according to Segmentation model
}
obj.push(segmentation)

Error output:

Cannot read property ' __$' of undefined\nTypeError: Cannot read property ' __$' of undefined\n at _updateParentPopulated (/Users/avichaishapira/IdeaProjects/bigvu-webserver/node_modules/mongoose/lib/types/documentarray.js:323:14)\n at CoreDocumentArray.push (/Users/avichaishapira/IdeaProjects/bigvu-webserver/node_modules/mongoose/lib/types/documentarray.js:187:5)\n

What is the expected behavior?

array.push is successful

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

Node v12.10.0
Mongoose v5.7.8
MongoDB v3.3.0

@nsberndt
Copy link

nsberndt commented Nov 8, 2019

I experienced the same issue, specifically in version 5.7.8 vs. 5.7.7. It seems there is a bug in the latest patch release.

Reverting to 5.7.7 fixed the issue for me, but I would anticipate others are going to continue to experience this bug in 5.7.8.

I believe it may be related to 9b0e96d .

@ShazzyK
Copy link

ShazzyK commented Nov 8, 2019

Facing same issue, reverting to 5.7.7 fixed it for me as well. It is occuring when pushing to a document array placed within a findOne query. Here are my error logs:

events.js:174
throw er; // Unhandled 'error' event
[0] ^
[0]
[0] TypeError: Cannot read property '$__' of undefined
[0] at _updateParentPopulated (C:\X\X\X\X\X\node_modules\mongoose\lib\types\documentarray.js:323:14)
[0] at CoreDocumentArray.push (C:\X\X\X\X\X\node_modules\mongoose\lib\types\documentarray.js:187:5)
[0] at userModel.findOne (C:\X\X\X\X\X\NewsfeedServer.js:132:20)
[0] at C:\X\X\X\X\X\node_modules\mongoose\lib\model.js:4600:16
[0] at C:\X\X\X\X\X\node_modules\mongoose\lib\query.js:4351:12
[0] at process.nextTick (C:\X\X\X\X\X\node_modules\mongoose\lib\query.js:2849:28)
at process._tickCallback (internal/process/next_tick.js:61:11)
[0] Emitted 'error' event at:

@vkarpov15 vkarpov15 added this to the 5.7.12 milestone Nov 14, 2019
@vkarpov15 vkarpov15 added the needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue label Nov 14, 2019
@vkarpov15
Copy link
Collaborator

Should be fixed by #8351 in 5.7.12

@nbcraft
Copy link

nbcraft commented Nov 20, 2019

@vkarpov15
In 5.7.12 (but also 5.7.7) calling .splice on a CoreDocumentArray errors this out:

     TypeError: Cannot read property 'casterConstructor' of undefined
      at CoreDocumentArray._cast (node_modules/mongoose/lib/types/documentarray.js:46:47)
      at CoreDocumentArray.splice (node_modules/mongoose/lib/types/core_array.js:759:16)
      at CoreDocumentArray.splice (node_modules/mongoose/lib/types/documentarray.js:234:30)

Is this related to this issue? Am I doing something wrong?
Thanks in advance.

EDIT:
Happens in 5.6.13 - Seems to be CoreMongooseArray then
Looks fine in 5.5.15 - Still CoreMongooseArray
Looks fine in 5.0.18 - Is a a regular JS Array then though, so that makes sense.

@vkarpov15
Copy link
Collaborator

@nbcraft the issue you're experiencing looks slightly different, looks like a different error message. Can you please open up a separate issue and follow the issue template?

@Automattic Automattic locked as resolved and limited conversation to collaborators Dec 1, 2019
@vkarpov15 vkarpov15 removed the needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue label Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants