Git Product home page Git Product logo

Comments (5)

aichbauer avatar aichbauer commented on June 20, 2024

can you provide the exact error message?

from express-routes-mapper.

Fabian-Fynn avatar Fabian-Fynn commented on June 20, 2024

Sure
remove-provisional is interpreted as :userId, which is expected but the error could inform what's wrong

{ CastError: Cast to ObjectId failed for value "remove-provisional" at path "_id" for model "User"
    at new CastError (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/error/cast.js:27:11)
    at ObjectId.cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schema/objectid.js:158:13)
    at ObjectId.SchemaType.applySetters (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:724:12)
    at ObjectId.SchemaType._castForQuery (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:1095:15)
    at ObjectId.castForQuery (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schema/objectid.js:198:15)
    at ObjectId.SchemaType.castForQueryWrapper (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/schematype.js:1064:15)
    at cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/cast.js:300:32)
    at model.Query.Query.cast (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:3216:12)
    at model.Query.Query._castConditions (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:1286:10)
    at model.Query.Query._findOne (/Users/Fabi/Sites/node-project-boilerplate/node_modules/mongoose/lib/query.js:1502:8)
    at process.nextTick (/Users/Fabi/Sites/node-project-boilerplate/node_modules/kareem/index.js:315:33)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
  message: 'Cast to ObjectId failed for value "remove-provisional" at path"_id" for model "User"',
  name: 'CastError',
  stringValue: '"remove-provisional"',
  kind: 'ObjectId',
  value: 'remove-provisional',
  path: '_id',
  reason: undefined,
  model:
   { [Function: model]
     hooks: Kareem { _pres: [Object], _posts: [Object] },
     base:
      Mongoose {
        connections: [Array],
        models: [Object],
        modelSchemas: [Object],
        options: [Object],
        _pluralize: [Function: pluralize],
        plugins: [Array] },
     modelName: 'User',
     model: [Function: model],
     db:
      NativeConnection {
        base: [Object],
        collections: [Object],
        models: [Object],
        config: [Object],
        replica: false,
        options: null,
        otherDbs: [],
        relatedDbs: {},
        states: [Object],
        _readyState: 1,
        _closeCalled: false,
        _hasOpened: true,
        _listening: false,
        _connectionOptions: [Object],
        client: [Object],
        name: 'projectName',
        '$initialConnection': [Object],
        db: [Object] },
     discriminators: undefined,
     '$appliedMethods': true,
     '$appliedHooks': true,
     schema:
      Schema {
        obj: [Object],
        paths: [Object],
        aliases: {},
        subpaths: {},
        virtuals: [Object],
        singleNestedPaths: {},
        nested: [Object],
        inherits: {},
        callQueue: [],
        _indexes: [],
        methods: [Object],
        statics: {},
        tree: [Object],
        query: {},
        childSchemas: [],
        plugins: [Array],
        s: [Object],
        _userProvidedOptions: [Object],
        options: [Object],
        '$globalPluginsApplied': true,
        _requiredpaths: [],
        _indexedpaths: [Array] },
     collection:
      NativeCollection {
        collection: [Object],
        opts: [Object],
        name: 'users',
        collectionName: 'users',
        conn: [Object],
        queue: [],
        buffer: false,
        emitter: [Object] },
     Query: { [Function] base: [Object] },
     '$__insertMany': [Function],
     '$init': Promise { [Circular], catch: [Function] } } }

from express-routes-mapper.

aichbauer avatar aichbauer commented on June 20, 2024

But this is a error message from mongoose. So there is nothing that can be done here. Or what do you mean?

from express-routes-mapper.

Fabian-Fynn avatar Fabian-Fynn commented on June 20, 2024

Well this error is thrown when mongoose tries to cast remove-provisional to ObjectId
Maybe it's possible to catch that error and suggest what the problem could be
Or throw an error when a route /model/action is found after a /model/:modelId route

from express-routes-mapper.

aichbauer avatar aichbauer commented on June 20, 2024

But we cannot implement error messages for another library... if message: 'Cast to ObjectId failed for value "remove-provisional" at path"_id" for model "User"', has too less information, that should be added in mongoose.

from express-routes-mapper.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.