Sequelize TypeError: Cannot read property '1' of null

Normally this type of error would not be a problem but i simply cannot understand where this is happening:

Here is my setup:

router.route('/api/academyModule')
.post(function (req, res) {

    req.body.academyModule.module_id = req.body.academyModule.module.id;
    req.body.academyModule.module_module_type_id = req.body.academyModule.module.module_type.id;
    var am = AcademyModule.build(req.body.academyModule);
    am.add(req.body.academyModule.requirements, req.body.academyModule, function (success) {
            res.json({id: this[null]});

        },
        function (err) {
            res.status(err).send(err);
        });
    if(req.body.teams != null)
    {
        req.body.teams.forEach(function(y)
        {
            var atm = academy_team_has_academy_module.build({academy_team_id: y.id, academy_id: y.academy_id, academy_module_module_id: req.body.academyModule.module_id })
            atm.add(function(success)
            {

            }, function(err)
            {
                res.status(err).send(err);
            });
        });
    }
})

For this i have the following model:

    academy_team_has_academy_module = sequelize.define('academy_team_has_academy_module', {
    academy_team_id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: false
    },
    academy_id: DataTypes.INTEGER,
    academy_module_module_id: DataTypes.INTEGER
}, {
    freezeTableName: true,
    instanceMethods: {
        add: function (onSuccess, onError) {
            academy_team_has_academy_module.build(this.dataValues)
                .save().ok(onSuccess).error(onError);
        }
    }
});

i know for sure this happens in this model and not AcademyModule because when i remove this code it runs without any issues. So in my console i get the following print out:

    Executing (default): INSERT INTO `requirements` (`id`,`value`,`requirement_type_id`) VALUES (DEFAULT,5,'2');
Executing (default): INSERT INTO `academy_team_has_academy_module` (`academy_team_id`,`academy_id`,`academy_module_module_id`) VALUES (1,3,11);
Executing (default): INSERT INTO `academy_module` (`academy_id`,`module_id`,`module_module_type_id`,`sort_number`,`requirements_id`) VALUES ('3',11,4,4,40);

And just right after i get:

    /var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Parser.js:82
        throw err;
              ^
TypeError: Cannot read property '1' of null
    at module.exports.Query.formatError (/var/www/learningbankapi/src/node_modules/sequelize/lib/dialects/mysql/query.js:155:23)
    at Query.module.exports.Query.run [as _callback] (/var/www/learningbankapi/src/node_modules/sequelize/lib/dialects/mysql/query.js:38:23)
    at Query.Sequence.end (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24)
    at Query.ErrorPacket (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/sequences/Query.js:93:8)
    at Protocol._parsePacket (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Protocol.js:271:23)
    at Parser.write (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Parser.js:77:12)
    at Protocol.write (/var/www/learningbankapi/src/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.Connection.connect (/var/www/learningbankapi/src/node_modules/mysql/lib/Connection.js:82:28)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.stream.pause.paused (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:526:21)

Ive debugged the whole thing and i can't seem to find any undefined variables. What might have gone wrong here?

Your problem is a ForeignKeyContraintError. Sequelize is trying to throw a new error but get's an unexpected error.message. If your configuration is fine, this may be an bug of sequelize.

Maybe deactivating foreign contraint checks (if possible) will solve your problem.

See: https://github.com/sequelize/sequelize/blob/master/lib/dialects/mysql/query.js#L153