Value "1739608289390985071" is out of range for type integer [BigInt]

Expected behavior

Search for “1739608289390985071” should give result for field objectId organization/1739608289390985071

Failure Logs

error: value "1739608289390985071" is out of range for type integer
    at Parser.parseErrorMessage (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:278:15)
    at Parser.handlePacket (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/var/www/forest-admin-production/node_modules/pg-protocol/dist/index.js:10:42)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

Context

Please provide any relevant information about your setup.

  • Package Version: forest-express-sequelize 7.0.3
  • Express Version: 4.17.1
  • Sequelize Version: ~5.15.1
  • Database Dialect: pg
  • Database Version: 9.4
  • Project Name: I don’t want this to be public

Hello @JonasKman,

Thank you for your feedback and welcome to the ForestAdmin community.

Could you please tell me what is the action your are performing when getting this error message? Is it an error server side (where your Forest agent runs) or in your browser?

It would help if I could identify your project. If not sharing the name could you please share with me the values for theses headers, found in the request made from your admin panel to our servers:

Forest-Environment-Id: ...
Forest-Project-Id: ...
Forest-Rendering-Id: ...
Forest-Team-Id: ...

Could you also share the table definition in your Postgres schema and the model file generated by Lumber for your project?

Thank you

Hello @Guillaume_Deslandes ,
We have Java Longs as ids. (which is sometimes to big for JS).
When doing a search in the main search field of this collection the error occurs on our forest agent (server side)

Database Table

create table subscription
(
    id                        bigint       not null
        constraint subscription_pkey
            primary key,
    version                   bigint       not null,
    date_created              timestamp    not null,
    end_date                  timestamp    not null,
    last_updated              timestamp    not null,
    note                      varchar(255),
    object_id                 varchar(255) not null,
    product_id                bigint       not null
        constraint fk1456591d9c2000c2
            references product,
    quantity                  integer,
    renewal_type              varchar(255) not null,
    share_it_purchase_item_id bigint
        constraint fk1456591d2390c009
            references purchase_item,
    start_date                timestamp    not null
);

Model

const { decryptWithFixedSalt, encryptWithFixedSalt } = require('../services/encrypted-fields');
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const Subscription = sequelize.define(
    'subscription',
    {
      version: {
        type: DataTypes.BIGINT,
        allowNull: false,
      },
      dateCreated: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      endDate: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      lastUpdated: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      note: {
        type: DataTypes.STRING,
        get() {
          return decryptWithFixedSalt(this.getDataValue('note'));
        },
        set(value) {
          return this.setDataValue('note', encryptWithFixedSalt(value));
        },
      },
      objectId: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      quantity: {
        type: DataTypes.INTEGER,
      },
      renewalType: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      startDate: {
        type: DataTypes.DATE,
        allowNull: false,
      },
    },
    {
      tableName: 'subscription',
      underscored: true,
      timestamps: false,
      schema: process.env.DATABASE_SCHEMA,
    }
  );

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  Subscription.associate = (models) => {
    Subscription.belongsTo(models.purchaseItem, {
      foreignKey: {
        name: 'shareItPurchaseItemIdKey',
        field: 'share_it_purchase_item_id',
      },
      as: 'shareItPurchaseItem',
    });
    Subscription.belongsTo(models.product, {
      foreignKey: {
        name: 'productIdKey',
        field: 'product_id',
      },
      as: 'product',
    });
    Subscription.hasMany(models.license, {
      foreignKey: {
        name: 'subscriptionIdKey',
        field: 'subscription_id',
      },
      as: 'licenses',
    });
    Subscription.hasMany(models.productKey, {
      foreignKey: {
        name: 'subscriptionIdKey',
        field: 'subscription_id',
      },
      as: 'productKeys',
    });
  };

  return Subscription;
};

Note: The encrypted getter/setter is the only change I did.

Forest-Environment-Id: 68385
Forest-Project-Id: 54928
Forest-Rendering-Id: 82745
Forest-Team-Id: 54359

Hi @JonasKman,

I’m totally able to reproduce, thanks to your database dump. I’m still investigating to see if there is a quick fix for this - and I will post here if I find something, and I’ll open a ticket on our end.
Could you confirm that the issue appear only on search, not when using filter ?

Thanks for reporting this :raised_hands:

2 Likes

Yes I can confirm it is working when using as a filter value. Independent of the filtered field being bigint or varchar(255).

1 Like

Hey @JonasKman ,

We are currently working on a fix. You can’t track the status here:

1 Like

Hi @JonasKman,

The error you faced should be fixed in the version 7.6.3 of forest-express-sequelize.
Could you update it and tell me if it is working properly now?

Thanks! :raised_hands:

2 Likes

It works as expected now, thanks for the quick fix :smiley:

2 Likes