question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CastError: Cast to Embedded failed for value

See original GitHub issue

Upgrading to 4.6.2 is causing an error to be thrown:

CastError: Cast to Embedded failed for value  "{ label: 'DEFAULT LABEL',
  token: '',
  _id: 'r1LxVo1gA' }" at path "childSchemaKey" at MongooseError.CastError

We have a schema that used the the above schema { label, token, id } as a child under they key ‘childSchemaKey’. 4.6.1 and prior does not throw any errors.

Any idea what is causing this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
vkarpov15commented, May 13, 2017

Looks like the embedded value is a string not an object @sandeepaboutclinic . Check typeof doc.address before saving.

0reactions
vkarpov15commented, Apr 13, 2019

@hirengevariya please don’t double post

Read more comments on GitHub >

github_iconTop Results From Across the Web

MongooseError: Cast to embedded failed for value
To make this work, we have to change the type of the productId from Number to String. So, if you're receiving an cast...
Read more >
Cast to embedded failed for value "{ value: 'x' }" at path "items ...
After updating to Mongoose 5.11.13 I am getting the following error when trying to add an item to a sub-object inside a document....
Read more >
Cast error inserting array (embedded documents) using ...
Cast error inserting array (embedded documents) using Mongoose? ... "message": "Cast to undefined_method failed for value \"[object Object],[object ...
Read more >
Node.js – MongooseError: Cast to embedded failed for value
Node.js – MongooseError: Cast to embedded failed for value. mongodbmongoosenode.js. I'm creating a mongoose Schema but I'm getting a MongooseError .
Read more >
CastError: Cast to Number failed for value "undefined" (type ...
... i got this mongodb error CastError: Cast to Number failed for value “undefined” (type string) at path i could not find how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found