Skip to content

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

@christian-schwaderer

Description

@christian-schwaderer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    has repro scriptThere is a repro script, the Mongoose devs need to confirm that it reproduces the issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions