Having to restart our forest pod so that the right options appear in a select field of smart action


We have a orders, and on the orders, we have a smart action to add order items. Order items have a kind, that is a select field to pick from.

There are 3 kinds:

  • Coliving Damage → this kind is only available when the order is of a specific kind (5)
  • Manual Coliving & Manual Service → the rest of the time, these kinds should be available

It happens that sometimes, instead of having Manual Coliving & Manaul Service to be available on the select field, we have the Coliving Damage type.

When this problem happen, our only solution is to restart the Forest pod so that it goes back to place. This solution works great, but we don’t know why Forest derail like this…

The code of the action looks something like this:

  name: 'Add credit/debit',
  type: 'single',
  endpoint: '/forest/actions/orders/add_order_item',
  fields: [{
    field: 'kind',
    type: 'Enum',
    enums: ['Manual Service', 'Manual Coliving'],
    isRequired: true,
  }, {
    field: 'description',
    type: 'String',
    isRequired: true,
  }, {
    field: 'price',
    description: 'Price in € without VAT. If you\'re adding room damages to a deposit refund, please put the price including VAT.',
    type: 'Number',
    isRequired: true,
  }, {
    field: 'vat',
    description: 'You can add any rate when the kind is service. Otherwise, fill in 0',
    type: 'Number',
    isRequired: true,
  hooks: {
    load: async ({ fields, request }) => {
      const id = request.body.data.attributes.ids[0]
      const totalPrice = await computeOrderTotalPrice(id)
      const ordersRes = await sequelize.query(readQueryLocal(`${__dirname}/sql/fields/kind_type.sql`), {
        replacements: { order_id: id },
        type: sequelize.QueryTypes.SELECT,
      const kindType = await getKindType(ordersRes, totalPrice)
      if (kindType === 5) {
        const kindField = fields.find(field => field.field === 'kind')
        kindField.enums = ['Coliving Damage']
      return fields

Any idea how we could correct this so that the behaviour is constant and that we don’t have to restart our pod?
Thanks a lot!

Hi @MaximeRobion :wave: pretty strange behavior indeed, Have you noticed some error on your browser console or your server logs ?
Your smart action code looks good, does function like getKindType or computeOrderTotalPrice can be return some invalid result ?

Hey Arnaud, thanks for your quick reply. I’ll gather the answer to your question and come back to you as soon as I can.

1 Like

Hey Arnaud:

  • No errors on the logs or console
  • The functions returns valid results because we use them also for other smartfields which work while the action is not working.

As we speak we’re having the error, but it might disappear in 2 days for some obscure reason haha.
Also, super important data, while it doesn’t work on Prod, it does work on Staging & Preprod at the same moment.

Also, while we relaunch the pod on the 30/12, in order to fix the behaviour, we didn’t push anything to prod until today, when the bug reappeared.

To try to find the culprit, can you check the payload response of the load hook and check if it have the right data?
If not, can you check with the request payload on your data or like you can, if the load behavior are ok?