Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property because of object depth #111

Open
bybrunobarros opened this issue Aug 3, 2018 · 0 comments
Open

Cannot set property because of object depth #111

bybrunobarros opened this issue Aug 3, 2018 · 0 comments

Comments

@bybrunobarros
Copy link

bybrunobarros commented Aug 3, 2018

Expected behavior

I should be able to access a collection in ForestAdmin

Actual behavior

I get the message "Oops, something went wrong" when I try to access a collection

Failure Logs

error [forest] 馃尦馃尦馃尦  Unexpected error: Cannot set property 'stats' of null
Cannot set property 'stats' of null
    at /var/app/node_modules/forest-express/dist/serializers/resource.js:60:29
    at arrayMap (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:614:23)
    at Function.map (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:8561:14)
    at getAttributesFor (/var/app/node_modules/forest-express/dist/serializers/resource.js:46:9)
    at /var/app/node_modules/forest-express/dist/serializers/resource.js:64:13
    at arrayMap (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:614:23)
    at Function.map (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:8561:14)
    at getAttributesFor (/var/app/node_modules/forest-express/dist/serializers/resource.js:46:9)
    at ResourceSerializer.perform (/var/app/node_modules/forest-express/dist/serializers/resource.js:149:5)
    at /var/app/node_modules/forest-express/dist/routes/resources.js:24:140
    at tryCatcher (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:454:31)
    at Promise._settlePromiseAt (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:530:18)
    at Promise._settlePromises (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:646:14)
    at Async._drainQueue (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:177:16)
    at Async._drainQueues (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:187:10)
    at Immediate.Async.drainQueues (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

Context

The issue seems to come from the depth of my model

new Schema({
  // ...
  meta: {
    stats: {
      updatedAt: {type: Date, default: Date.now()},
      // ...
    }
  }
})

I could fix this by adding a condition if (!_.isNil(dest) && _.isPlainObject(field.type)) here https://github.com/ForestAdmin/forest-express/blob/8bd2bb1e91c29c7955dd82a951b868044519cab6/src/serializers/resource.js#L59.
But it's a parent project, so I don't know the consequences this fix can have on forest-express-sequelize.

  • Package Version: 2.12.0
  • Express Version: 4.16.2
  • Mongoose Version: 5.2.4
  • MongoDB Version: 3.6.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant