Can't create data

Hello all,

I’ve been getting this error recently only in production and not on the development environment.

Table creation failed: related bookings with pk undefined does not exist.

The model named “Tables” has multiple associations. With the Bookings table I have two:

Tables.belongsTo(models.bookings, {
			foreignKey: {
				name: "bookingIdKey",
				field: "bookingId",
			},
			as: "booking",
		});

and

Tables.hasMany(models.bookings, {
			foreignKey: {
				name: "bookingIdKey",
				field: "tableId",
			},
			as: "bookings",
		});

Do any of you spot an error?

What’s weird is that it is only happening on the production environment…

Thanks
David

Hello @daweido

I am sorry to read that you are facing some issues with ForestAdmin

I would need additional issue in order to assist you :pray:

  • Can you please check that the .forestadmin-schema.json (can be found in the root folder of your project) file is up to date on production environment with your local version (it is only recalculated on development environments)?

  • If yes, can you please check the version of forest-express-sequelize on both production and development environments?

The answers to those questions would really help me to try to reproduce your issue.

Thank you

Hello @olesyak,

Thanks for replying.

The .forestadmin-schema.json are identical. I just checked using a diff tool and there are no differences.

Concerning the version of forest-express-sequelize, they are the same on the production and on the development environment.

Thank you.
David

Thank you for your reply!

I have some more questions to guide me to the rootcause.

  • Could you please share with me the name of the project so I can check internally if I find any issues?

  • What is the version of the forest-express-sequelize that you use?

  • Are you testing with the same user on both the development and production environment?

  • Did this issue appeared recently or is it present since you deployed the production environment?

  • Could you also please do a screencast using loom for example to illustrate the scenario that leads to the error?

  • Is this case the only one failing on production or do you have some other CRUD operations working on the development environment but not in production?

Thanks for taking the time to help me understand the issue

Thank you for your reploy

The project is “Lords”.

The version being used is "forest-express-sequelize": "^6.6.3",

Yes, it is the same user, same version, same environment copy.

It appeared very recently. The last element I have changed was on another model having nothing to do with the table in question.

Ok, I just realised that it doesn’t work on any of the tables I have created… Now that’s a real bummer.

Thank you for your assistance.
David

could you please try specifying "forest-express-sequelize": "6.7.4", just to make sure you have the latest version? Some errors are related to specific minor versions of the package, so it would be safer to have the latest one.

Can you think of any changes that you made to the production environment? Some package upgrades? Addition of some new features? Anything? :thinking:

Can you remember when was the last time it was working and any changes that you would have made to the project since then?

Would you mind also sharing with me the definition of the Table model from .forestaadmin-schema.json? If you don’t want to share it here publicly you can send it to me via messages.

I just updated my sequelize version. I will however not be able to deploy until tomorrow.

I have added a new model, but I don’t understand why it would work locally but not in production.

I will send to you my file via message.

Hello @olesyak,

I managed to test with the changes you suggested.

BTW, I tried to see if the error still occurred when having the same data in development and production environment. On the development env it works like a charm, but not on the production env.

Hope I can find a solution for this.

Hello @daweido ,

Could you please share with us:

  1. The HTTP request sent to your liana, and that leads to this error? We need the data posted and the response from the liana
  2. If there are any error in the console in your frontend, we would like to have them also.

Have you tried specifying the version of forest-express-sequelize as mentionned by @olesyak ?

In your package.json, the version ^6.6.3 means, "any version compatible with the 6.6.3", as a consequence, the version actually installed depends on the moment of the first installation occurred. You may have different versions of forest-express-sequelize in dev and in production because of this parameter.

Hello @GuillaumeGautreau,

So I just put my production env as development so I can get all the logs.

Here is the error:

Jan 28 18:31:10 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` LIMIT 0, 100;
Jan 28 18:31:10 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` LIMIT 0, 100;
Jan 28 18:31:10 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` LIMIT 0, 100;
Jan 28 18:31:10 ip-172-31-28-0 web: Executing (default): SELECT `codeNameId`, `codeName` FROM `codeNames` AS `codeNames` LIMIT 0, 100;
Jan 28 18:31:10 ip-172-31-28-0 web: GET /forest/tips?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=tip%202&context%5Bcollection%5D=tables&context%5BrecordId%5D=&page%5Bnumber%5D=1&page%5Bsize%5D=100&search=&searchToEdit=false&timezone=Europe%2FParis 304 - - 42.940 ms
Jan 28 18:31:10 ip-172-31-28-0 web: GET /forest/tips?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=tip%201&context%5Bcollection%5D=tables&context%5BrecordId%5D=&page%5Bnumber%5D=1&page%5Bsize%5D=100&search=&searchToEdit=false&timezone=Europe%2FParis 304 - - 41.992 ms
Jan 28 18:31:10 ip-172-31-28-0 web: GET /forest/tips?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=tip%203&context%5Bcollection%5D=tables&context%5BrecordId%5D=&page%5Bnumber%5D=1&page%5Bsize%5D=100&search=&searchToEdit=false&timezone=Europe%2FParis 304 - - 41.736 ms
Jan 28 18:31:10 ip-172-31-28-0 web: GET /forest/codeNames?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=codeName&context%5Bcollection%5D=tables&context%5BrecordId%5D=&page%5Bnumber%5D=1&page%5Bsize%5D=100&search=&searchToEdit=false&timezone=Europe%2FParis 304 - - 43.886 ms
Jan 28 18:31:15 ip-172-31-28-0 web: OPTIONS /forest/restaurants?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=restaurant&context%5Bcollection%5D=tables&context%5BrecordId%5D=&fields%5Brestaurants%5D=restaurantName&search=gala&searchToEdit=true&timezone=Europe%2FParis 204 0 - 0.179 ms
Jan 28 18:31:15 ip-172-31-28-0 web: Executing (default): SELECT `restaurantId`, `restaurantName`, `restaurantDescription`, `restaurantImagePath`, `cityId` AS `restaurantIdKey`, `cityId` AS `cityIdKey` FROM `restaurants` AS `restaurants` WHERE ((lower(`restaurants`.`restaurantName`)  LIKE  lower('%gala%') OR lower(`restaurants`.`restaurantDescription`)  LIKE  lower('%gala%') OR lower(`restaurants`.`restaurantImagePath`)  LIKE  lower('%gala%'))) LIMIT 0, 10;
Jan 28 18:31:15 ip-172-31-28-0 web: GET /forest/restaurants?context%5Brelationship%5D=BelongsTo&context%5Bfield%5D=restaurant&context%5Bcollection%5D=tables&context%5BrecordId%5D=&fields%5Brestaurants%5D=restaurantName&search=gala&searchToEdit=true&timezone=Europe%2FParis 200 333 - 7.471 ms
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m[forest] 🌳🌳🌳  Unexpected error: related bookings with pk undefined does not exist.#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31mError: related bookings with pk undefined does not exist.#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Object.get (/var/app/current/node_modules/forest-express-sequelize/dist/utils/association-record.js:13:11)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at processTicksAndRejections (internal/process/task_queues.js:97:5)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at runNextTicks (internal/process/task_queues.js:66:3)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at processImmediate (internal/timers.js:434:9)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at async ResourceCreator._getTargetKey (/var/app/current/node_modules/forest-express-sequelize/dist/services/resource-creator.js:35:22)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at async ResourceCreator._makePromisesBeforeSave (/var/app/current/node_modules/forest-express-sequelize/dist/services/resource-creator.js:45:25)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31mFrom previous event:#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at ResourceCreator._handleSave (/var/app/current/node_modules/forest-express-sequelize/dist/services/resource-creator.js:78:15)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at ResourceCreator.perform (/var/app/current/node_modules/forest-express-sequelize/dist/services/resource-creator.js:88:16)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at /var/app/current/node_modules/forest-express/dist/routes/resources.js:76:64#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at tryCatcher (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/util.js:16:23)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromiseFromHandler (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:547:31)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:604:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise0 (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:649:10)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromises (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:729:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._fulfill (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:673:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._resolveCallback (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:466:57)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromiseFromHandler (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:559:17)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:604:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise0 (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:649:10)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromises (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:729:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._fulfill (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:673:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray._resolve (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:127:19)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray._promiseFulfilled (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:145:14)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray._iterate (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:115:31)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray.init [as _init] (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:79:10)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:601:21)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise0 (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:649:10)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromises (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:729:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._fulfill (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:673:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray._resolve (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:127:19)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at PromiseArray._promiseFulfilled (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise_array.js:145:14)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:609:26)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromise0 (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:649:10)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Promise._settlePromises (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/promise.js:729:18)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at _drainQueueStep (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/async.js:93:12)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at _drainQueue (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/async.js:86:9)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Async._drainQueues (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/async.js:102:5)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at Immediate.Async.drainQueues (/var/app/current/node_modules/forest-express/node_modules/bluebird/js/release/async.js:15:14)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: #033[31m    at processImmediate (internal/timers.js:461:21)#033[39m
Jan 28 18:31:29 ip-172-31-28-0 web: POST /forest/tables 500 89 - 20.238 ms
Jan 28 18:31:29 ip-172-31-28-0 web: Executing (default): SELECT `restaurantId`, `restaurantName`, `restaurantDescription`, `restaurantImagePath`, `cityId` AS `restaurantIdKey`, `cityId` AS `cityIdKey` FROM `restaurants` AS `restaurants` WHERE `restaurants`.`restaurantId` = '1';
Jan 28 18:31:29 ip-172-31-28-0 web: Executing (default): SELECT `codeNameId`, `codeName` FROM `codeNames` AS `codeNames` WHERE `codeNames`.`codeNameId` = '1';
Jan 28 18:31:29 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` WHERE `tips`.`tipId` = '1';
Jan 28 18:31:29 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` WHERE `tips`.`tipId` = '2';
Jan 28 18:31:29 ip-172-31-28-0 web: Executing (default): SELECT `tipId`, `amount` FROM `tips` AS `tips` WHERE `tips`.`tipId` = '3';

And yes I have done everything that @olesyak has suggested me to try out.

Thanks.

Hello @daweido,

Thanks for sharing us your logs it will help us a lot to investigate. I setup a project trying to be as similar as your project and it seems that the bug you are facing was introduced recently. Can you try to set the forest-express-sequelize version to → "forest-express-sequelize": "6.7.2" and tell me if the bug persits on your end?

I hope this can help you.

1 Like

Hello @lclisson,

Just did the changes you suggested, and it works. Thank you so much!

This means there is a problem with the newer versions of forest-express-sequelize ?

Cheers!

A change seems to have introduced a bug, I reported the problem in our bugtracking system so we can fix it. Here is the bug. :slight_smile:

Cheers !

1 Like

Hello @daweido,

A new version of forest-express-sequelize has been released fixing the bug you encountered :slight_smile:
Please update to the latest, and everything should be back to mormal.

Let me know :wink:

1 Like

Hello @Guillaume_Cisco,

I have updated and it is up and running. :white_check_mark:

Thank you so much for your reactiveness, really appreciate it.

1 Like