Segment crashes depending on filter

I’ve created 2 segments. One is working just fine, the other one crashes :

Your server encountered an error

In my dev back-end, I get the following message :
[forest] ��� 'browseEnabled' access forbidden on preEtatDateRequests

For the crashing segment, the routes

  • http://localhost:3310/forest/preEtatDateRequests
  • http://localhost:3310/forest/preEtatDateRequests/count
    return a
    403 Forbidden code

If, in my segment filters, I add another filter, the segment doesn’t crash anymore.

Hello @JeremyV ,

Can you please give me a little more context on the segments created. Do you have errors in the console or on your backend server?

The best way for us to understand your error and help you solve it is to share with us a video of your screen reproducing the error via a tool like loom for example or by sharing us screen capture of your error. :slight_smile:

Here’s a working segment

Here’s the one which doesn’t :

I’m making a vid soon for your guys

Hello @JeremyV

Are you trying to create both segments on the same collection in the same environment for the same user?

Can you please tell me if your project uses a roles-based permissions system?

Thank you

Sorry I didn’t time yet to make a video.

Are you trying to create both segments on the same collection in the same environment for the same user?

Yes, absolutely

Can you please tell me if your project uses a roles-based permissions system?

No it doesn’t

Could you please give me the name of your project, the environment, the team, and the collection you are trying to achieve the creation on?

And could you please tell me what database you are using? And give me the exact package version of forest-express-<databaseDialect> package you are using?

It can be done with npm list forest-express-sequelize for example.

Thank you for your help :slightly_smiling_face:

Project: Sergic
Environment: Dev
Team: Syndic ONE
Collection: Pré États Datés (preEtatDateRequests)

Using a postgre SQL DB.
syndic-one-rebirth@0.0.1 C:\Users\jvollant\WebDev\Syndic One Rebirth
`-- forest-express-sequelize@6.7.1

And here is a video:

Hi @JeremyV,

To be able to reproduce, could you share with me the model definition of your preEtatDateRequests collection?

Thank you

Here you are :

module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;

  const PreEtatDateRequests = sequelize.define('preEtatDateRequests', {
    agreementDate: {
      type: DataTypes.DATE,
      allowNull: false,
    },
    createdAt: {
      type: DataTypes.DATE,
    },
    updatedAt: {
      type: DataTypes.DATE,
    },
    state: {
      type: DataTypes.ENUM([
        'created',
        'etat_date_pending',
        'urgent',
        'etat_date_created',
        'waiting_mutation',
        'canceled',
        'mutation_done',
      ]),
    },
    saleDate: {
      type: DataTypes.DATE,
    },
    notaryEmail: {
      type: DataTypes.STRING,
    },
    notaryName: {
      type: DataTypes.STRING,
    },
  }, {
    tableName: 'pre_etat_date_requests',
    underscored: true,
    schema: process.env.DATABASE_SCHEMA,
  });

  PreEtatDateRequests.associate = (models) => {
    PreEtatDateRequests.belongsTo(models.contracts, {
      foreignKey: {
        name: 'contractIdKey',
        field: 'contract_id',
      },
      as: 'contract',
    });

    PreEtatDateRequests.belongsToMany(models.parcels, {
      through: 'preEtatDateRequestsParcels',
      foreignKey: 'pre_etat_date_request_id',
      otherKey: 'parcel_id',
      as: 'pTPEDRp',
    });
  };
  return PreEtatDateRequests;
};

It seems that the segment crashed when there is no record matching the filter, which is no longer the case. However, it should not return an error when there is no record.

Hello @JeremyV ! I think I managed to reproduce your error, that I didn’t have on an older version of forest-express-sequelize !

I’m going to open a ticket for your issue, we’ll surely keep you updated when it’s fixed!

Here is the ticket I just created, so that you can see live when it’s fixed!

1 Like

Hi @JeremyV,

After many tries with your forest-express-sequellize version and others, I haven’t been able to reproduce the issue.

The issue Remi spotted gave the same issue but was unrelated to yours.

To check if it could fix your issue, could you try to remove the segment and add it back again?

If the error persist, and it is still blocking for you, could you also try upgrading your forest-express-sequelize dependency version to v7, following or upgrade guide: Upgrade to v7 - Documentation

I hope all of this will help you get rid of this issue.

Best regards,

TY @lamatt_v

As I stated before it seems to crash when there is no matching records, which is currently not the case. I’ll monitor this and let you know.

Cheers

1 Like