Errors after upgrading to v7 - sequelize

Expected behavior

Having followed the instructions to upgrade to V7 w/ sequelize, herev7 , I run docker-compose up and expect the node service to start up as usual.

Actual behavior

After the usual Your application is listening on port 3310., I get lots of exceptions -

One per model field for every single model (as far as I can tell) looking like this:

Followed by a single error as follows:


The forestadmin-schema.json file is not autogenerated (as suggested by that last error).

I HAVE confirmed that models/index.js has the right models dir, and is able to connection.import what looks like a valid model.

Context

My project is using Typescript. Autogenerated files remain in JS, but we’re writing new ones in TS.

  • forest-express-sequelize Version: 7.8.0
  • Express Version: 4.17.1
  • Sequelize Version: 5.15.2
  • Database Version: PostgreSQL 12.4
  • Project Name: empathy-backoffice

Thanks for helping!

Hello @Oded_Magger, and welcome to our community :raised_hands:

Could you share one of the model that is causing issue (In private if you consider is at sensitive data), the Liana.init and the models/index.js code part so I can investigate on your issue?

Thanks in advance

1 Like

Thank you! Sending you privately so I won’t spam the forum :slight_smile: .

The model I’m sending was auto-generated , and not manipulated by us.

@Oded_Magger
It appear to me that your Liana.init is not up-to-date with the v7 requirements.

You can get the full code for the middleware/forestadmin.js file here

module.exports = async function (app) {
  app.use(await Liana.init({
    configDir: path.join(__dirname, '../forest'),
    envSecret: process.env.FOREST_ENV_SECRET,
    authSecret: process.env.FOREST_AUTH_SECRET,
    objectMapping: sequelize.Sequelize, // Sequelize was already exported in v6
    connections: { default: sequelize }, // sequelize was already a connection in v6
  }));

Let me know if it fixes your issue :pray:

I took the files from the wrong branch - my bad. Re-sending the post-update ones. Sorry!

I can’t find any issue in the last files you shared. Everything seems correctly set, so no issues here.

I have just read the code associated with the 2nd error (options of undefined), so the issue is most likely located in config/databases.js, could I ask you to also share this file? Sorry for the inconvenience here, I could have asked this in the first place.

Thanks for your help :raised_hands:

No inconvenience, I greatly appreciate the effort :slight_smile: .

Attached.
forest_databases_js.tar.gz (510 Bytes)

1 Like

Hey,

Still no luck, this file looks good to me, no issue here…

I double checked the node_modules/forest-express-sequelize/dist/index.js, and line 113 does not use the options variable. I have something mentionning options line 119 (which is the only line mentionning options by the way), (Object.values(opts.connections)[0].options.dialect), but in your case, the connections value seems correctly set. I would suggest to try logging this in your project, just to check that the value returned is actually ok.

The first issue seems also to point out an issue with the objectMapping attribute (Since it is used afterward to extract DataTypes and generate your .forestadmin-schema.json), but again, I can’t see any issue in the files you shared with me :confused:

I also tried generating a new project (From scratch) using the informations you gave me, and I can’t reproduce.

Do you have, by any chance, a way for me to reproduce this behavior?

Well, in fact, I may have found the culprit here :slight_smile:

Could you also check the return value of npm ls forest-express-sequelize?
It looks like I’m having the exact same output when I switch back to forest-express-sequelize v6 on a v7 project syntax.

1 Like

My local env does have the latest package version:

However, I’m running the forest admin service in Docker, and the latest package is not installed there - despite the fact the Dockerfile has npm install.

It gets more interesting - when I try to run docker-compose build, I get the following error:

In package-lock.json , @types/forest-express-sequelize 's version is 7.5.0

So this might be a Typescript thing, perhaps?

Hi @Oded_Magger :wave:
In order to try to reproduce your issue, can you give me your Dockerfile, your docker-compose file.
And the dependencies object of your package.json please.

It seems we have an issue on our types.
What i suggest is to remove it from your package.json while waiting for us to fix it.
Or you can downgrade the version to 6.3.0, but the types doesn’t really march the reality.

Let me know if it help.

1 Like

Thanks so much!
I did the upgrade on a separate branch, so I’ll wait with merging until the fix is available.

Hi! Any news on when will the fix be available? To my understanding, this blocks any Forest project using Typescript from upgrading to v7.

Hello @Oded_Magger :wave:

Sorry for the late answer.

We have been working on new types and documentation to use Typescript in V7 project.

We are about to release the new types + documentation really soon (beginning of next week I would say).

I will ping you back on this thread with every new info as soon as we release every thing.

Thanks for your patience, and sorry for the inconvenience.

Steve.

Thank you, @Steve_Bunlon !

I see today’s the final day before the agent version I’m running locally will no longer be supported.

Will I be blocked from using my local forest environment starting tomorrow?

If so, is there’s any chance to push back the deprecation date until this issue is resolved?

Thanks :slight_smile: !

Hello @Oded_Magger :wave:

What’s the error you are encountering from TypeScript ?

Let’s see if we can work around it :slight_smile:

Just for you information, Types are almost finished, we are about to release them today / tomorrow. However it will be more confortable for you to get your current version running, and work with new types later on with more time :slight_smile:

Steve.

Thanks for the prompt response!

I understand from Errors after upgrading to v7 - sequelize - #12 by Arnaud_Moncel that the types fix should fix my issue as well, so I don’t want to take your time finding a workaround for something that’s going to be fixed within the next couple of days :slight_smile: .

Hello @Oded_Magger :wave:

I am glad to announce that the new Types implementation has just been released :tada:

To benefit from the new Types, you just have to upgrade your Liana to version 7.12.0. Yes, Types our now directly integrated in the forest-express-sequelize repository, you don’t need to install @types/forest-express-sequelize anymore :confetti_ball:

To help you with your migration, we also created a documentation to guide you as much as possible, please refer to this link.

Don’t hesitate to post any issue or frustration you encounter regarding Types, we will be glad to help you out and every feedback are appreciated.

Thanks for your patience, I hope you will enjoy the new version !

Steve.

1 Like