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

Update from 8.8.2 to 8.8.3 causes "Uncaught TypeError: Invalid path. Must be either string or array" #15071

Open
2 tasks done
christian-schwaderer opened this issue Dec 3, 2024 · 3 comments
Labels
needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
Milestone

Comments

@christian-schwaderer
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.8.3

Node.js version

20.18.0

MongoDB server version

7

Typescript version (if applicable)

No response

Description

I tried upgrading Mongoose from 8.8.2 to 8.8.3. But when trying to create a document I got this issue:

Uncaught TypeError: Invalid `path`. Must be either string or array
      at Object.exports.get (node_modules/mpath/lib/index.js:59:11)
      at Object.exports.getValue (Role node_modules/mongoose/lib/utils.js:624:16)
      at model.Document.$__getValue (Role node_modules/mongoose/lib/document.js:1771:16)
      at getSubdocs (Role node_modules/mongoose/lib/document.js:3695:23)
      at model.Document.$getAllSubdocs (Role node_modules/mongoose/lib/document.js:3723:3)
      at _getPathsToValidate (Role node_modules/mongoose/lib/document.js:2714:25)
      at model.Document.$__validate (Role node_modules/mongoose/lib/document.js:2980:25)
      at node_modules/kareem/index.js:497:25
      at processTicksAndRejections (node:internal/process/task_queues:77:11)

Tried to look a little bit and it seems that the problematic line is for (const { path } of doc.$__schema.childSchemas) {
It seems my schema has a paths property but not a path property and hence an undefined value is passed down. But that's where my knowledge ends. Cannot say how come.

Steps to Reproduce

Sorry but I cannot paste hundreds of lines of company code in here. I have no idea where in my schema the problem is.

Expected Behavior

No response

@hansgen
Copy link

hansgen commented Dec 5, 2024

We're experiencing the same issue.

@maximilianschmid
Copy link

Same here

@vkarpov15 vkarpov15 added this to the 8.9.1 milestone Dec 14, 2024
@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 Dec 14, 2024
@vkarpov15
Copy link
Collaborator

Without a repro script there's no way for us to guarantee a fix, but in #15098 we added some logic to improve this error message and a potential (but unlikely) fix. Can anyone in this thread please provide a script that demonstrates this issue or some sample code that can give us some hints?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro script Maybe a bug, but no repro script. The issue reporter should create a script that demos the issue
Projects
None yet
Development

No branches or pull requests

4 participants