CastError: Cast to ObjectId failed for value "{ type: 'Buffer' } Please help!

eric morrison
eric morrison used Ask the Experts™
on
Created a duplicate username entry in mongoose database and resulted in duplicated error. Now everytime I start server, I get this error:

(node:14839) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CastError: Cast to ObjectId failed for value "{ type: 'Buffer',
  data: [ 89, 243, 30, 231, 66, 69, 45, 56, 123, 65, 153, 72 ] }" at path "_id" for model "users"
(node:14839) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Don't know without seeing the real code, but I usually get a "cast" error on a buffer because the .toString(encoding) is missing (when a string is required)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial