# Segment crashes depending on filter

**URL:** https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895
**Category:** Help me!
**Created:** [February 22, 2021, 10:02am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895 "2021-02-22T10:02:52Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 22, 2021, 10:02am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/1 "2021-02-22T10:02:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![anon16419211](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anon16419211](https://community.forestadmin.com/u/anon16419211)
#### Post date: [February 22, 2021, 1:19pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/2 "2021-02-22T13:19:36Z")

</div>

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](https://www.loom.com/) for example or by sharing us screen capture of your error. 🙂

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 23, 2021, 8:34am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/3 "2021-02-23T08:34:45Z")

</div>

Here’s a working segment

 ![Screenshot 2021-02-23 093158](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/d/d3b6d2c15a054aa0635bfcf722264ced777c57af.png)

Here’s the one which doesn’t :

 ![Screenshot 2021-02-23 093241](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/1/1a61f0d38600850774b8c5638774fd22526b97ca.png)

I’m making a vid soon for your guys

---

<div class="post-metadata">

### Author: ![anon90145840](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon90145840](https://community.forestadmin.com/u/anon90145840)
#### Post date: [February 23, 2021, 12:15pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/4 "2021-02-23T12:15:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 23, 2021, 2:52pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/5 "2021-02-23T14:52:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anon90145840](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon90145840](https://community.forestadmin.com/u/anon90145840)
#### Post date: [February 23, 2021, 3:38pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/6 "2021-02-23T15:38:06Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 24, 2021, 9:39am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/7 "2021-02-24T09:39:31Z")

</div>

> [@anon90145840](#):
>
> 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?

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

> [@anon90145840](#):
>
> 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?

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

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 24, 2021, 9:48am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/8 "2021-02-24T09:48:20Z")

</div>

And here is a video:

---

<div class="post-metadata">

### Author: ![anon37102731](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon37102731](https://community.forestadmin.com/u/anon37102731)
#### Post date: [February 24, 2021, 3:36pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/9 "2021-02-24T15:36:29Z")

</div>

Hi @JeremyV,

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

Thank you

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 25, 2021, 9:15am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/10 "2021-02-25T09:15:18Z")

</div>

Here you are :

```javascript
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;
};

```

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [February 25, 2021, 9:48am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/11 "2021-02-25T09:48:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![remi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/remi/32/334_2.png) [@remi](https://community.forestadmin.com/u/remi)
#### Post date: [February 25, 2021, 12:51pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/12 "2021-02-25T12:51:55Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![remi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/remi/32/334_2.png) [@remi](https://community.forestadmin.com/u/remi)
#### Post date: [February 25, 2021, 4:07pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/13 "2021-02-25T16:07:36Z")

</div>

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

https://share.clickup.com/t/h/ev4ek7/RLD295J364SCGAF

---

<div class="post-metadata">

### Author: ![anon37102731](https://avatars.discourse-cdn.com/v4/letter/a/c6cbf5/32.png) [@anon37102731](https://community.forestadmin.com/u/anon37102731)
#### Post date: [March 1, 2021, 9:48am UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/14 "2021-03-01T09:48:53Z")

</div>

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](https://docs.forestadmin.com/documentation/how-tos/maintain/upgrade-notes-sql-mongodb/upgrade-to-v7#upgrading-to-v7)

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

Best regards,

---

<div class="post-metadata">

### Author: ![JeremyV](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jeremyv/32/1033_2.png) [@JeremyV](https://community.forestadmin.com/u/JeremyV)
#### Post date: [March 1, 2021, 1:35pm UTC](https://community.forestadmin.com/t/segment-crashes-depending-on-filter/1895/15 "2021-03-01T13:35:19Z")

</div>

TY @anon37102731

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
