robertcampion / dredd

Scoring software for the MRDC (Midwestern Robotics Design Competition)
1 stars 0 forks source link

Trying to submit game actions results in a server-side error #1

Closed robertcampion closed 8 years ago

robertcampion commented 8 years ago

When clicking on any of the game action buttons after a team is selected

The error message is:

POST /api/games/56e48b975439548905db2efe/actions 500 60.148 ms - 708

Digging a little further gives me this stack trace:

{ ValidationError: CastError: Cast to ObjectID failed for value "{ _bsontype: 'ObjectID',
  id: <Buffer 57 db c3 00 2d d8 7b 07 9c 8e bc f5> }" at path "_id"
    at MongooseError.ValidationError (/home/robert/dredd/node_modules/mongoose/lib/error/validation.js:22:11)
    at model.Document.invalidate (/home/robert/dredd/node_modules/mongoose/lib/document.js:1410:32)
    at Document.Subdocument.invalidate (/home/robert/dredd/node_modules/mongoose/lib/types/subdocument.js:64:18)
    at Document.set (/home/robert/dredd/node_modules/mongoose/lib/document.js:703:10)
    at Document.set (/home/robert/dredd/node_modules/mongoose/lib/document.js:548:18)
    at SchemaType.Embedded.cast (/home/robert/dredd/node_modules/mongoose/lib/schema/embedded.js:111:12)
    at SchemaType.applySetters (/home/robert/dredd/node_modules/mongoose/lib/schematype.js:628:12)
    at model.Document.set (/home/robert/dredd/node_modules/mongoose/lib/document.js:695:18)
    at model.set [as currentState] (/home/robert/dredd/node_modules/mongoose/lib/document.js:1712:25)
    at model.GameSchema.methods.addAction (/home/robert/dredd/server/api/game/game.model.js:95:20)
    at /home/robert/dredd/server/api/game/game.controller.js:114:12
...

Not sure why this happens, since 57 db c3 00 2d d8 7b 07 9c 8e bc f5 is a valid ObjectId.

This error did not occur last year; my guess is there is some change in behavior between mongoose 4.1.2 (initial version) and 4.6.0 (my current version).