Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'get' of null #211

Open
jabm111 opened this issue Oct 1, 2018 · 1 comment
Open

TypeError: Cannot read property 'get' of null #211

jabm111 opened this issue Oct 1, 2018 · 1 comment
Labels

Comments

@jabm111
Copy link

jabm111 commented Oct 1, 2018

Expected behavior

I have two models involved: guides and steps. I expect to be able to create a guide and create steps associated with that guide from the Forest Admin web interface. I sent this issue to support@forestadmin.com but I'm posting it here in case someone from the community has had a similar issue and might have a solution.

Actual behavior

I am able to create a guide but when I try to create a step associated with that guide no network request is made and an error is logged to the console. This error was not occurring the last time I tried it (September 19) and we've made no model/code changes in several months.

Steps to reproduce:

  • login to Forest admin and create a guide
  • click on steps (from the left of this guide details, so that it will be associated with this guide)
  • click on the + -> create new step
  • fill out the required fields and click save
  • nothing happens. no network request is made and the error below is logged to the console

guides model:

"use strict";
module.exports = function(sequelize, DataTypes) {
    var guides = sequelize.define("guides", {
        title: {
            type: DataTypes.STRING,
            allowNull: true
        },
        subtitle: {
            type: DataTypes.STRING,
            allowNull: true
        },
        image: {
            type: DataTypes.STRING,
            allowNull: true
        },
        image_thumbnail: {
            type: DataTypes.STRING,
            allowNull: true
        },
        description: {
            type: DataTypes.TEXT,
            allowNull: true
        },
        product_identifier: {
            type: DataTypes.STRING,
            allowNull: true
        },
        archive: {
            type: DataTypes.STRING,
            allowNull: true
        },
        reduced_mobility: {
            type: DataTypes.BOOLEAN,
            defaultValue: false,
            allowNull: false
        },
        language: {
            type: DataTypes.ENUM("fr", "en"),
            defaultValue: "fr",
            allowNull: false
        },
        credit_image: {
            type: DataTypes.STRING,
            allowNull: true
        },
        link: {
            type: DataTypes.STRING,
            allowNull: true
        },
        archive_size_string: {
            type: DataTypes.STRING,
            allowNull: true
        },
        archive_size_bytes: {
            type: DataTypes.INTEGER,
            allowNull: true
        },
        order: {
            type: DataTypes.INTEGER,
            allowNull: false,
            defaultValue: 1
        },
        autoplay: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: false
        },
        onsite_limit: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: false
        },
        environment: {
            type: DataTypes.ENUM("development", "staging", "production"),
            defaultValue: "development",
            allowNull: false
        },
        guide_type: {
            type: DataTypes.ENUM("navigation", "audio", "parcour"),
            defaultValue: "navigation",
            allowNull: false
        },
        is_free: {
            type: DataTypes.BOOLEAN,
            allowNull: false,
            defaultValue: false
        }
    });

    guides.associate = function(models) {
        guides.hasMany(models.steps);
        guides.belongsTo(models.locations, {
            foreignKey: "start_location_id",
            as: "start_location"
        });
        guides.belongsTo(models.locations, {
            foreignKey: "end_location_id",
            as: "end_location"
        });
    };

    return guides;
};

steps model:

'use strict';
module.exports = function(sequelize, DataTypes) {
    var steps = sequelize.define('steps', {
        order: {
            type: DataTypes.INTEGER,
            allowNull: true,
            validate: {
                min: 0,
            },
        },
        playlist_title: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        playlist_instruction: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        title: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        meta: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        description: {
            type: DataTypes.TEXT,
            allowNull: true,
        },
        image: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        image_thumbnail: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        audio: {
            type: DataTypes.STRING,
            allowNull: true,
        },
        guide_id: {
            type: DataTypes.INTEGER,
            allowNull: false,
            references: {
                model: 'guides',
                key: 'id',
            },
        },
        step_type: {
            type: DataTypes.STRING,
            allowNull: false,
            defaultValue: 'other',
        },
        autoplay_group: {
            type: DataTypes.STRING,
            allowNull: false,
            defaultValue: 'none',
        },
        ext_id: {
            type: DataTypes.INTEGER,
            allowNull: true,
        },
        ext_data: {
            type: DataTypes.TEXT,
            allowNull: true,
        },
        ext_updated_at: {
            type: DataTypes.STRING,
            allowNull: true,
        },
    });

    steps.associate = function(models) {
        steps.belongsTo(models.guides);
        steps.belongsToMany(models.beacons, { through: 'step_beacon' });
    }

    return steps;
};

Failure Logs

TypeError: Cannot read property 'get' of null
    at client-5fdff9cef7c56…54b566218f6.js:1177
    at o.forEach (vendor-039ff5e8d2118…4f25499893e.js:3532)
    at o.saveNewRecord (client-5fdff9cef7c56…54b566218f6.js:1176)
    at o.y (vendor-039ff5e8d2118…4f25499893e.js:3287)
    at d (vendor-039ff5e8d2118…4f25499893e.js:3932)
    at E.trigger (vendor-039ff5e8d2118…4f25499893e.js:4089)
    at o.send (vendor-039ff5e8d2118…4f25499893e.js:3323)
    at o.send (vendor-039ff5e8d2118…4f25499893e.js:3494)
    at o.triggerAction (vendor-039ff5e8d2118…4f25499893e.js:3600)
    at o.sendAction (vendor-039ff5e8d2118…4f25499893e.js:3759)

Context

  • Package Version: 2.16.2 (in dev and staging) 2.8.2 (in production)
  • Express Version: 4.15.2
  • Sequelize Version: 4.8.3
  • Database Dialect: mysql
  • Database Version: mysql Ver 14.14 Distrib 5.5.60, for debian-linux-gnu (x86_64) using readline 6.3

Thanks!

@arnaudbesnier
Copy link
Member

Hey @jabm111,
Thank you for the feedback.

We've released a batch of fixes recently and your issue really looks like an issue we've fixed.
Could you retry and let us know if we can close the issue?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants