Strange blocker issue during setup

I’ve run into a strange blocker issue in setting up Forest Admin, and would love some help please.

In late December 2020 I was able to successfully create a project to test out Forest Admin. I created a development MySQL database (RDS on AWS) with a recent copy of our system data, and was able to get the Forest Admin back-end successfully running locally on my machine. Everything connected and I was able to login through the Forest Admin Web interface and check out a lot of the functionality. I was very happy with how seamlessly that quick test went.

Yesterday, I tried to run another test in preparation to explore and evaluate Forest Admin further. I had ended up deleting the original project in the Forest Admin system, so I created a new project and started the process of creating the Docker image and running it as I had done before in December. I used the exact same development MySQL DB which was still running from earlier; there were no changes made to the DB in the interim and I am the only one using it. However, when I ran docker-compose up for the new project I got the following error:

occu_admin_test_1 | /usr/src/app/node_modules/sequelize/lib/associations/has-many.js:138
occu_admin_test_1 |     this.sourceKeyField = this.source.rawAttributes[this.sourceKey].field || this.sourceKey;
occu_admin_test_1 |                                                                     ^
occu_admin_test_1 | 
occu_admin_test_1 | TypeError: Cannot read property 'field' of undefined
occu_admin_test_1 |     at HasMany._injectAttributes (/usr/src/app/node_modules/sequelize/lib/associations/has-many.js:138:69)
occu_admin_test_1 |     at Function.hasMany (/usr/src/app/node_modules/sequelize/lib/associations/mixin.js:37:17)
occu_admin_test_1 |     at Function.Groupings.associate (/usr/src/app/models/groupings.js:54:15)
occu_admin_test_1 |     at Object.keys.forEach (/usr/src/app/models/index.js:48:19)
occu_admin_test_1 |     at Array.forEach (<anonymous>)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/models/index.js:46:17)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/routes/api-keys.js:3:21)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at /usr/src/app/node_modules/require-all/index.js:56:46
occu_admin_test_1 |     at Array.forEach (<anonymous>)
occu_admin_test_1 |     at requireAll (/usr/src/app/node_modules/require-all/index.js:34:9)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/app.js:56:1)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/server.js:5:13)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | npm ERR! code ELIFECYCLE
occu_admin_test_1 | npm ERR! errno 1
occu_admin_test_1 | npm ERR! occu-admin-test1@0.0.1 start: `node ./server.js`
occu_admin_test_1 | npm ERR! Exit status 1
occu_admin_test_1 | npm ERR! 
occu_admin_test_1 | npm ERR! Failed at the occu-admin-test1@0.0.1 start script.
occu_admin_test_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
occu_admin_test_1 | 
occu_admin_test_1 | npm ERR! A complete log of this run can be found in:
occu_admin_test_1 | npm ERR!     /root/.npm/_logs/2021-01-22T23_40_47_366Z-debug.log
occu_admin_test_1 exited with code 1

I tried the NPM route as well and also got the same error. I also tried the entire process on a new EC2 instance in AWS and experienced the same error.

What’s happening here and how can this be resolved? It’s very strange as the DB is the exact same as before when it worked; the data has not changed at all on that machine and I followed the same steps as before. The only thing that I found that is different versus late December is that lumber itself has updated (I noticed that it pulled a new image dated as of 9 days ago). Any chance that is related?

Any guidance you can provide would be greatly appreciated.

Thanks! Nick

Hi @nick_r ,

It’s certainly related to that lumber update. I’m going to investigate and try to reproduce your issue. I’ll keep you posted

I could not reproduce your issue :thinking:
Is that happening when you start your server or when accessing a specific record ?
Could you please share your models too ? Especially the grouping one

Hi Vince, thanks for your reply. I get that error when I try to run docker-compose up, or npm start. So the error happens on startup (I have been unable to get it to startup at all).

Below is my groupings.js model. Please let me know if there are others that you would like to see (and if there is a better way to share them with you other than posting them here):

// 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 Groupings = sequelize.define('groupings', {
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  }, {
    tableName: 'groupings',
    timestamps: false,
  });

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  Groupings.associate = (models) => {
    Groupings.belongsTo(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parent',
    });
    Groupings.belongsTo(models.zones, {
      foreignKey: {
        name: 'zoneIdKey',
        field: 'zone_id',
      },
      as: 'zone',
    });
    Groupings.belongsTo(models.customers, {
      foreignKey: {
        name: 'customerIdKey',
        field: 'customer_id',
      },
      as: 'customer',
    });
    Groupings.hasMany(models.apiKeys, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupApiKeys',
    });
    Groupings.hasMany(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parentGroupings',
    });
    Groupings.hasMany(models.userLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      sourceKey: 'groupId',
      as: 'groupUserLocations',
    });
    Groupings.hasMany(models.waitzLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzLocations',
    });
    Groupings.hasMany(models.waitzSublocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzSublocations',
    });
  };

  return Groupings;
};

Hello @nick_r,

Thank you for these information :slight_smile:
Would that be possible for you to share with us the sql definition of tables waitzLocations and groupings please?

I suspect the sourceKey: 'groupId', to be the issue, maybe if you remove it, will it work?

For now, you can try to generate your project with an older version of lumber.
Let me know if it helps :slight_smile:

Thanks for your reply.

I will try with an older version of lumber, I am curious to see what that does too. Can you please give me some instructions on the best/quickest way to pull an older version of lumber? I am using the Docker image method.

And here are the table definitions you asked for:

CREATE TABLE `groupings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) NOT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `zone_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `parent_id` (`parent_id`),
  KEY `groupings_ibfk_2` (`zone_id`),
  KEY `groupings_ibfk_3` (`customer_id`),
  CONSTRAINT `groupings_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `groupings` (`id`) ON DELETE CASCADE,
  CONSTRAINT `groupings_ibfk_2` FOREIGN KEY (`zone_id`) REFERENCES `zones` (`id`) ON DELETE CASCADE,
  CONSTRAINT `groupings_ibfk_3` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=540 DEFAULT CHARSET=latin1;


CREATE TABLE `waitz_locations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group_id` int(11) NOT NULL DEFAULT '0',
  `customer_id` int(11) NOT NULL DEFAULT '0',
  `category` int(11) DEFAULT '0',
  `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `best_label` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `label` (`category`),
  KEY `group_id` (`group_id`),
  KEY `customer_id` (`customer_id`),
  CONSTRAINT `waitz_locations_ibfk_1` FOREIGN KEY (`category`) REFERENCES `waitz_location_categories` (`id`),
  CONSTRAINT `waitz_locations_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `groupings` (`id`),
  CONSTRAINT `waitz_locations_ibfk_3` FOREIGN KEY (`customer_id`) REFERENCES `waitz_customers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Hello @nick_r,

In order to use an older version of lumber, you’ll have to choose the npm method for installing your agent. But even with this method, you’ll be able to run the server with docker.

You’ll have to have node installed on your machine for it to work.

  1. Create a new project on Forest Admin
  2. Choose the NPM method
  3. Fill in your credentials
  4. Instead of the first command, run npm install -g lumber-cli@3.9.1, it will use an older version of lumber
  5. Copy/paste the second command to generate your project
  6. You can copy/paste the code you added in your previous project
  7. In order to start your agent with docker, run docker-compose up in your new directory

In the meantime, I will try to reproduce your issue with the info you copied in your answer.

Hello,

I could not reproduce either on my side, with a simple example from your table definition.

Could you please comment all the associations in your Groupins model, and un-comment them one by one, just to see which one is causing the issue?

It seems related to a hasMany relationship, but I don’t see which one. If there is only one failing association, it’ll give us some clues about the origin of your problem.

Hi Guillaume, thanks for your continued replies, I appreciate your help.

I commented out all the groupings in groupings.js as it still gave an error when trying to startup. Below is my revised groupings.js file with the comments so you can see what I did, and the error that I got on startup.

groupings.js file:

// 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 Groupings = sequelize.define('groupings', {
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  }, {
    tableName: 'groupings',
    timestamps: false,
  });

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  Groupings.associate = (models) => {


/*    
    Groupings.belongsTo(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parent',
    });
    Groupings.belongsTo(models.zones, {
      foreignKey: {
        name: 'zoneIdKey',
        field: 'zone_id',
      },
      as: 'zone',
    });
    Groupings.belongsTo(models.customers, {
      foreignKey: {
        name: 'customerIdKey',
        field: 'customer_id',
      },
      as: 'customer',
    });
    Groupings.hasMany(models.apiKeys, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupApiKeys',
    });
    Groupings.hasMany(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parentGroupings',
    });
    Groupings.hasMany(models.userLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      sourceKey: 'groupId',
      as: 'groupUserLocations',
    });
    Groupings.hasMany(models.waitzLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzLocations',
    });
    Groupings.hasMany(models.waitzSublocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzSublocations',
    });
  };

*/

  return Groupings;
};

Error Message Received:

Starting occu_admin_test_1 … done
Attaching to occu_admin_test_1
occu_admin_test_1 |
occu_admin_test_1 | > occu-admin-test1@0.0.1 start /usr/src/app
occu_admin_test_1 | > node ./server.js
occu_admin_test_1 |
occu_admin_test_1 | Model creation error: SyntaxError: Unexpected end of input
occu_admin_test_1 | /usr/src/app/node_modules/sequelize/lib/associations/mixin.js:93
occu_admin_test_1 | throw new Error(${source.name}.${_.lowerFirst(Type.name)} called with something that's not a subclass of Sequelize.Model);
occu_admin_test_1 | ^
occu_admin_test_1 |
occu_admin_test_1 | Error: apiKeys.belongsTo called with something that’s not a subclass of Sequelize.Model
occu_admin_test_1 | at Function. (/usr/src/app/node_modules/sequelize/lib/associations/mixin.js:93:13)
occu_admin_test_1 | at Function.ApiKeys.associate (/usr/src/app/models/api-keys.js:23:13)
occu_admin_test_1 | at Object.keys.forEach (/usr/src/app/models/index.js:48:19)
occu_admin_test_1 | at Array.forEach ()
occu_admin_test_1 | at Object. (/usr/src/app/models/index.js:46:17)
occu_admin_test_1 | at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 | at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 | at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 | at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 | at Object. (/usr/src/app/routes/api-keys.js:3:21)
occu_admin_test_1 | at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 | at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 | at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 | at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 | at /usr/src/app/node_modules/require-all/index.js:56:46
occu_admin_test_1 | at Array.forEach ()
occu_admin_test_1 | at requireAll (/usr/src/app/node_modules/require-all/index.js:34:9)
occu_admin_test_1 | at Object. (/usr/src/app/app.js:56:1)
occu_admin_test_1 | at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 | at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 | at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 | at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 | at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 | at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 | at Object. (/usr/src/app/server.js:5:13)
occu_admin_test_1 | at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 | npm ERR! code ELIFECYCLE
occu_admin_test_1 | npm ERR! errno 1
occu_admin_test_1 | npm ERR! occu-admin-test1@0.0.1 start: node ./server.js
occu_admin_test_1 | npm ERR! Exit status 1
occu_admin_test_1 | npm ERR!
occu_admin_test_1 | npm ERR! Failed at the occu-admin-test1@0.0.1 start script.
occu_admin_test_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
occu_admin_test_1 |
occu_admin_test_1 | npm ERR! A complete log of this run can be found in:
occu_admin_test_1 | npm ERR! /root/.npm/_logs/2021-01-27T18_31_32_796Z-debug.log
occu_admin_test_1 exited with code 1

Does that help you in diagnosis? Or let me know if I did something incorrectly with my commenting in groupings.js.

In the meantime, I will start to explore using a previous version of lumber. Thanks!

For what I can seen, you commented too many lines :slight_smile:

The last one should be uncommented. Here you have a syntax error in your file, which is a whole other kind of error :slight_smile:

Whoops! I should have noticed that, thank you. I moved the comment block up one level of indentation, and tried it again. This time I got the same error as before (originally) and shown below. This is with all associations commented out groupings.js.

Starting occu_admin_test_1 ... done
Attaching to occu_admin_test_1
occu_admin_test_1 | 
occu_admin_test_1 | > occu-admin-test1@0.0.1 start /usr/src/app
occu_admin_test_1 | > node ./server.js
occu_admin_test_1 | 
occu_admin_test_1 | /usr/src/app/node_modules/sequelize/lib/associations/has-many.js:138
occu_admin_test_1 |     this.sourceKeyField = this.source.rawAttributes[this.sourceKey].field || this.sourceKey;
occu_admin_test_1 |                                                                     ^
occu_admin_test_1 | 
occu_admin_test_1 | TypeError: Cannot read property 'field' of undefined
occu_admin_test_1 |     at HasMany._injectAttributes (/usr/src/app/node_modules/sequelize/lib/associations/has-many.js:138:69)
occu_admin_test_1 |     at Function.hasMany (/usr/src/app/node_modules/sequelize/lib/associations/mixin.js:37:17)
occu_admin_test_1 |     at Function.Inventory.associate (/usr/src/app/models/inventory.js:69:15)
occu_admin_test_1 |     at Object.keys.forEach (/usr/src/app/models/index.js:48:19)
occu_admin_test_1 |     at Array.forEach (<anonymous>)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/models/index.js:46:17)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/routes/api-keys.js:3:21)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at /usr/src/app/node_modules/require-all/index.js:56:46
occu_admin_test_1 |     at Array.forEach (<anonymous>)
occu_admin_test_1 |     at requireAll (/usr/src/app/node_modules/require-all/index.js:34:9)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/app.js:56:1)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
occu_admin_test_1 |     at Module.load (internal/modules/cjs/loader.js:653:32)
occu_admin_test_1 |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
occu_admin_test_1 |     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
occu_admin_test_1 |     at Module.require (internal/modules/cjs/loader.js:692:17)
occu_admin_test_1 |     at require (internal/modules/cjs/helpers.js:25:18)
occu_admin_test_1 |     at Object.<anonymous> (/usr/src/app/server.js:5:13)
occu_admin_test_1 |     at Module._compile (internal/modules/cjs/loader.js:778:30)
occu_admin_test_1 | npm ERR! code ELIFECYCLE
occu_admin_test_1 | npm ERR! errno 1
occu_admin_test_1 | npm ERR! occu-admin-test1@0.0.1 start: `node ./server.js`
occu_admin_test_1 | npm ERR! Exit status 1
occu_admin_test_1 | npm ERR! 
occu_admin_test_1 | npm ERR! Failed at the occu-admin-test1@0.0.1 start script.
occu_admin_test_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
occu_admin_test_1 | 
occu_admin_test_1 | npm ERR! A complete log of this run can be found in:
occu_admin_test_1 | npm ERR!     /root/.npm/_logs/2021-01-28T07_56_25_610Z-debug.log
occu_admin_test_1 exited with code 1

One other thing to report, I was able to successfully follow your instructions to use an older version of lumber (3.9.1) with a new project and that started up and ran fine. I am able to see the web UI running in my browser. So the issue seems to be confirmed to a change in lumber.

Let me know if I can provide any more info or answer any questions.

Hi @nick_r,

When looking at the logs, I can see that after commenting the Groupings associations, the error looks the same but happens on another collection: Inventory. Which mean that at least one of the Groupings’s associations is breaking things.

In order to find what goes wrong, could I ask you to share the Groupings model generated with the not-breaking lumber version? This way I can try to spot what went wrong.

Ok no problem, here is the groupings.js generated with the non-breaking lumbar version:

// 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 Groupings = sequelize.define('groupings', {
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  }, {
    tableName: 'groupings',
    timestamps: false,
  });

  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
  Groupings.associate = (models) => {
    Groupings.belongsTo(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parent',
    });
    Groupings.belongsTo(models.zones, {
      foreignKey: {
        name: 'zoneIdKey',
        field: 'zone_id',
      },
      as: 'zone',
    });
    Groupings.belongsTo(models.customers, {
      foreignKey: {
        name: 'customerIdKey',
        field: 'customer_id',
      },
      as: 'customer',
    });
    Groupings.hasMany(models.apiKeys, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupApiKeys',
    });
    Groupings.hasMany(models.groupings, {
      foreignKey: {
        name: 'parentIdKey',
        field: 'parent_id',
      },
      as: 'parentGroupings',
    });
    Groupings.hasMany(models.userLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupUserLocations',
    });
    Groupings.hasMany(models.waitzLocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzLocations',
    });
    Groupings.hasMany(models.waitzSublocations, {
      foreignKey: {
        name: 'groupIdKey',
        field: 'group_id',
      },
      as: 'groupWaitzSublocations',
    });
  };

  return Groupings;
};

I also have another question please. I am trying to keep moving on our evaluation with the 3.9.1 version of lumber while you guys look into the issue. I need to put this on a remote server in AWS instead of running locally so that other folks can check it out as well. However, I am having problems getting it to run locally. Here is what I did:

  1. Provisioned an EC2 instance running Ubuntu
  2. Setup a load balancer to point to the EC2 instance, with traffic from the load balancer (either port 80 or 443) directed to port 3310 on the EC2 instance
  3. Setup a route 53 subdomain to map to the load balancer
  4. Made sure the load balancer security group is provisioned to allow inbound traffic from 80 and 443
  5. Made sure the EC2 security group allows inbound traffic from the load balancer
  6. Chose the Production deployment option in the FA portal when running locally
  7. Input the Route 53 subdomain that I setup into the first FA portal screen
  8. Input my RDS information into the second screen, it then gave me the values for the .env file and said it was waiting to connect to the back-end
  9. Used rsync to copy the back-end files from my local machine to the EC2 instance
  10. Made sure the .env file in the back-end directory has the values copied from the FA portal
  11. Also made sure that /etc/environment had the values copied from the FA portal
  12. Did npm install -s and then ran the back-end with npm start

The FA back-end server seems to start and attach itself to port 3310 successfully from what I see in the console. However, in the FA portal it stays at “Waiting to connect” and does not proceed any further.

Can you please advise here on what I might be doing wrong?

Thanks!

Following up on my last post/reply. I figured out the issue and was able to move my local environment to Production successfully. There was an error I had made in the LB setup. Please disregard that portion.

And on the original issue, let me know if I can provide any more information to help in the analysis.

Thanks.

Hello @nick_r ,

Thank you for your time and your detailed report.
Would that be ok for you to share with me the mysql definition of the table userLocations, please?

I’m trying to be as close as possible of your setup in order to reproduce the issue.

Let me know :slight_smile:

Yes sure, here you go. Please let me know if you need something else.

CREATE TABLE `user_locations` (
  `user_id` int(11) NOT NULL DEFAULT '0',
  `group_id` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`user_id`,`group_id`),
  KEY `user_id` (`user_id`),
  KEY `group_id` (`group_id`),
  CONSTRAINT `user_locations_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `user_locations_ibfk_2` FOREIGN KEY (`group_id`) REFERENCES `groupings` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

Hi @nick_r :wave: in order to reproduce your issue correctly, can you give me the version of mysql you are using.

Hi Arnaud, we are using MySQL 8.0.11. Let me know if you have other questions.

Hi @nick_r,

I have just created a MySQL 8.0.11 database, with all the models shared here using 3.10.7/3.10.8, and I’m still not able to reproduce…

If that possible, would you mind sharing a complete DDL of your database? (Can be in private if you don’t want it to be posted here). I have a complete setup which should looks like yours, so with that I expect this to be as close as I can to reproduce your issue.

Also

Are you able to access your lumber app using the domain you filled in the deployment flow (Outside the VPC/EC2 network)? Do you have any error logs in your browser for concerning this?

Thanks for your reply. Sure I can share the full DDL of the DB but would prefer to do that privately, please advise me on the best way to do that for you.

And regarding your second question, I managed to figure out the AWS deployment and no longer have that issue. Thank you for checking back on this.