I just updated our server to forest-express-sequelize
v7.8.0 following this doc and now have a weird behaviour where some association links work for one team but not for another.
I can reproduce this behaviour on all the envs where the new version is deployed.
Expected behavior
Association links work properly
Actual behavior
We have multiple teams set up, one for our operationals and another for support with more data accessible. Association links all work properly for support team but for operationals they are broken and display a server error.
The views of the associated objects are not accessible directly to the user but the objects are shown in the context of other objects (ex: operations have access to the orders
view but not the order items
view, items are accessible when checking an order)
Failure Logs
The following error appears in the logs (formatted for readability):
[forest] 🌳🌳🌳 Unexpected error: Cannot read property 'map' of undefined
{
"stack": "TypeError: Cannot read property 'map' of undefined
at Function._validateIncludedElements (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:511:39)
at Function._validateIncludedElement (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:707:38)
at /Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:516:37
at Array.map (<anonymous>)
at Function._validateIncludedElements (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:511:39)
at /Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:1728:14
at tryCatcher (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)"
}
Context
Please provide any relevant information about your setup.
- Package Version: 7.8.0
- Express Version: 4.17.1
- Sequelize Version: 5.15.1
- Database Dialect: postgres
- Database Version: 9.6
- Project Name:
Platform
Hi @cberez 
Have you see any difference on request send to your api?
Have you override some relationShip route?
Do you observe the issue on a specific relationship?
Hi @Arnaud_Moncel
- Here’s a sample of the requests logged, a failure and a success on the same relationship w/ different team
This one works (support team):
GET /forest/productSkus/119/relationships/plans?fields%5Bplans%5D=name%2Cslug%2Cprice%2Cvat%2Cdeposit_amount%2Cmin_income%2Cactivated_at%2Cinterval%2Cid%2CproductSku%2Ccommitment%2CcreatedAt%2CupdatedAt%2Cavailable%2Cretired_at%2CdeletedAt%2Cproduct%2Ctarget&fields%5BproductSku%5D=id&page%5Bnumber%5D=1&page%5Bsize%5D=50&timezone=Atlantic%2FReykjavik&sort=-id 200 327.031 ms - 3624
This one doesn’t (operations team):
GET /forest/productSkus/119/relationships/plans?fields%5Bplans%5D=available%2Cname%2Cprice%2Cvat%2Cdeposit_amount%2Cmin_income%2Ccommitment%2Cproduct%2Ctarget&page%5Bnumber%5D=1&page%5Bsize%5D=10&timezone=Atlantic%2FReykjavik&sort=-id 500 34.829 ms - 97
[forest] 🌳🌳🌳 Unexpected error: Cannot read property 'map' of undefined
{
"stack": "TypeError: Cannot read property 'map' of undefined\n at Function._validateIncludedElements (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:511:39)\n at Function._validateIncludedEle
ment (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:707:38)\n at /Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:516:37\n at Array.map (<anonymous>)\n
at Function._validateIncludedElements (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:511:39)\n at Function.aggregate (/Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/
lib/model.js:1958:12)\n at /Users/cesarberezowski/dev/platform/services/forest/node_modules/sequelize/lib/model.js:2049:19\n at tryCatcher (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/util.js:1
6:23)\n at Promise._settlePromiseFromHandler (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:547:31)\n at Promise._settlePromise (/Users/cesarberezowski/dev/platform/services/forest/nod
e_modules/bluebird/js/release/promise.js:604:18)\n at Promise._settlePromise0 (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:649:10)\n at Promise._settlePromises (/Users/cesarberezowsk
i/dev/platform/services/forest/node_modules/bluebird/js/release/promise.js:729:18)\n at _drainQueueStep (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:93:12)\n at _drainQueue (/Users/ces
arberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:86:9)\n at Async._drainQueues (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:102:5)\n at Immediate.Asy
nc.drainQueues [as _onImmediate] (/Users/cesarberezowski/dev/platform/services/forest/node_modules/bluebird/js/release/async.js:15:14)\n at processImmediate (internal/timers.js:456:21)\n at process.topLevelDomainCallback (domain.js:13
7:15)"
}
- The concerned relationships don’t have their routes overriden
- It’s on a defined set of relationships, not all, can’t find anything common between them (different models, on a given model only some fail not all)
The thing that bothers me is this team difference, if both failed I would expect an issue from our server but having an inconsistent behaviour between teams I have no idea what to look for 
We’re having the same issue
If you try to downgrade the forest-express-sequelize
package to version 7.7.0
, Is the issue persist?
@Arnaud_Moncel downgrading seems to fix it, don’t have the issue anymore
Do you advise to stay on 7.7.0? Or wait for a patch / fix / new version?
I suggest you to stay in 7.7.0 version until we reproduce, find and fix the bug.
We will notice you when the issue, we will let you know when the problem is solved.
In order to try to reproduce your issue
Oh do you “restrict” the access simply hide the collection?
Yes, we simply hide the collection
Will mark suggestion to downgrade to 7.7.0 until issue is fixed in 7.8.0
@austinrupie @cberez
Hello!
Arnaud reached for me as all commits between versions 7.7 and 7.8 on forest-express-sequelize have my name on them.
I can confirm that this is a regression on our side.
Sorry for that, and thank you for reporting it so soon.
I just managed to find a situation that triggers the same stacktrace that you are having, and I’m working on a fix + unit tests.
Will report again when it is released
@austinrupie @cberez @Arnaud_Moncel
I just created a PR that should solve the problem.
Once merged by the team (it should be done today), you will need to update to version 7.9.1 or more.
Again, sorry for the inconvenience and thank you for reporting the issue.