Cannot read property 'timezone' of undefined


I have an issue using the smart actions, I got this error message “Unexpected error with Valider action”.

Here is my action in my collection in forest folder

collection('tETherapist', {
  actions: [
      name: 'Valider',
      endpoint: '/forest/actions/therapist/valider'
      name: 'Refuser',
      endpoint: '/forest/actions/therapist/refuser'
  fields: [],
  segments: [],

Here is my smart action to update an enum field in the postgresql database in routes folder'/actions/therapist/valider', permissionMiddlewareCreator.smartAction(), (req, res) => {
  return new RecordsGetter(tETherapist).getIdsFromRequest(req)
    .then((therapistIds) => {
      return tETherapist
        .update({ registrationStatus: 'validated' }, { where: { id: therapistIds }})
        .catch(() => {
          res.send({ error: 'Le thérapeut n\'a pas pu être validé !' });
        .then(() => {
          res.send({ success: 'Thérapeut validé !' });

And here is the error log in the docker service from the docker compose

cajole_admin  | POST /forest/actions/therapist/valider?timezone=Europe%2FParis 500 102 - 7.945 ms
cajole_admin  | Executing (default): SELECT count("tETherapist"."id") AS "count" FROM "public"."t_e_therapist" AS "tETherapist" LEFT OUTER JOIN "public"."t_e_user" AS "user" ON "tETherapist"."user_id" = "user"."id" LEFT OUTER JOIN "public"."t_e_user" AS "sponsor" ON "tETherapist"."sponsor_id" = "sponsor"."id" WHERE "tETherapist"."id" IN ('f51fbde6-24f4-4a84-b069-64550767257e');
cajole_admin  | [forest] 🌳🌳🌳  Unexpected error: Cannot read property 'timezone' of undefined
cajole_admin  | {
cajole_admin  |   "stack": "TypeError: Cannot read property 'timezone' of undefined\n    at new AbstractRecordService (/usr/src/app/node_modules/forest-express/dist/services/exposed/abstract-records-service.js:20:17)\n    at RecordsGetter._createSuperInternal (/usr/src/app/node_modules/forest-express/dist/services/exposed/records-getter.js:27:317)\n    at new RecordsGetter (/usr/src/app/node_modules/forest-express/dist/services/exposed/records-getter.js:46:19)\n    at (/usr/src/app/routes/t-e-therapist.js:14:10)\n    at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n    at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)\n    at _callee2$ (/usr/src/app/node_modules/forest-express/dist/middlewares/permissions.js:205:53)\n    at tryCatch (/usr/src/app/node_modules/regenerator-runtime/runtime.js:63:40)\n    at Generator.invoke [as _invoke] (/usr/src/app/node_modules/regenerator-runtime/runtime.js:294:22)\n    at (/usr/src/app/node_modules/regenerator-runtime/runtime.js:119:21)\n    at asyncGeneratorStep (/usr/src/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)\n    at _next (/usr/src/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)"

Hello @Hsohm,

Welcome to our community :tada: :confetti_ball:

Can you confirm that you run on the latest version of forest-express-sequelize ?

Thanks in advance.

Hello @morganperre,

Thanks, I am on the ^8.0.9 version of forest-express-sequelize

Best regards,

Hey again,

We will try to reproduce on our end. In the meanwhile you can try to upgrade to the latest version ^8.1.0 (with force install to be sure that’s not related to node_module keeping an old version).


Ok, I tried 8.0.9 and 8.1.0 and I can reproduce on both versions with your setup.

But reading the upgrade note I found the solution.

// You need to add the user and query object to the RecordsGetter helper
return new RecordsGetter(comments, req.user, req.query)

One question remains, did you find some outdated documentation leading to your version of the code ?

Kind regards,

1 Like

Thanks for your answer, It fixed my issue by modifying this line

return new RecordsGetter(tETherapist, req.user, req.query).getIdsFromRequest(req)

My version of code is probably kind of outdated, the project started 2 months ago.

1 Like