Very large log/stacktrace for SequelizeValidationError: notNull Violation
See original GitHub issueWhat are you doing?
Trying to create a row using Sequelize, with some constraint not obeyed. We Sequelize to throw an error, but the error log ( stack trace ) is very large.
What do you expect to happen?
Error message and minimal stack trace
What is actually happening?
The following is the error log. I use winston.Logger.error()
and in many other cases, only the error and stacktrace are present, but here many code is output as well. The first few lines of the large error log is given below:
error: message=notNull Violation: MyModel.frequency cannot be null, stack=SequelizeValidationError: notNull Violation: MyModel.frequency cannot be null
at Promise.all.then (/Users/danedavid/app/app-v1/node_modules/sequelize/lib/instance-validator.js:74:15)
at bound (domain.js:396:14)
at runBound (domain.js:409:12)
at tryCatcher (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise_array.js:144:14)
at Promise._settlePromise (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:574:26)
at Promise._settlePromise0 (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/danedavid/app/app-v1/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:121:23), name=SequelizeValidationError, errors=[message=MyModel.frequency cannot be null, type=notNull Violation, path=frequency, value=null, origin=CORE, h=[4], m=[30], d=[1], active=true, count=0, failedCount=0, runAt=Thu Jan 01 1970 05:30:00 GMT+0530 (India Standard Time), lock=false, , id=null, frequency=undefined, updated_at=Wed Jun 26 2019 12:49:26 GMT+0530 (India Standard Time), created_at=Wed Jun 26 2019 12:49:26 GMT+0530 (India Standard Time), frequency=undefined, frequency=true, timestamps=true, , freezeTableName=false, underscored=true, paranoid=true, rejectOnEmpty=false, lock=false, active=true, , , schema=null, schemaDelimiter=, , , indexes=[fields=[account_id, run_at], type=, parser=null, name=nps_schedule_account_id_run_at, unique=true, fields=[], deleted_at=null, type=, parser=null], plural=MyModels, singular=MyModel, omitNull=false, createdAt=created_at, updatedAt=updated_at, deletedAt=deleted_at, tableName=nps_schedule, charset=utf8, collate=utf8_unicode_ci, dialect=postgres, dialectModule=null, dialectModulePath=null, host=localhost, protocol=tcp, createdAt=created_at, updatedAt=updated_at, deletedAt=deleted_at, , , timezone=+00:00, clientMinMessages=warning, standardConformingStrings=true, logging=(msg) => {
logger.info(msg);
}, omitNull=false, native=false, replication=false, ssl=undefined, max=10, min=3, idle=10000, acquire=30000, evict=9000, quoteIdentifiers=true, , max=5, match=[SQLITE_BUSY: database is locked], transactionType=DEFERRED, isolationLevel=null, databaseVersion=9.6.10, typeValidation=false, benchmark=false, port=5432, database=dummy, username=dummyuser, password=null, host=localhost, port=5432, $ref=$["errors"][0]["instance"]["_modelOptions"]["sequelize"]["options"]["pool"], protocol=tcp, native=false, ssl=undefined, replication=false, dialectModule=null, dialectModulePath=null, keepDefaultTimezone=undefined, dialectOptions=undefined, $ref=$["errors"][0]["instance"]["_modelOptions"]["sequelize"], $ref=$["errors"][0]["instance"]["_modelOptions"]["sequelize"], database=dummy, username=dummyuser, password=null, host=localhost, port=5432, max=10, min=3, idle=10000, acquire=30000, evict=9000, validate=function () { [native code] }, protocol=tcp, native=false, ssl=undefined, replication=false, dialectModule=null, dialectModulePath=null, keepDefaultTimezone=undefined, dialectOptions=undefined, user=dummyuser, $ref=$["errors"][0]["instance"]["_modelOptions"]["sequelize"]["dialect"], versionPromise=null, dialectName=postgres, name=sequelize, create=() => this._connect(config), destroy=connection => {
return this._disconnect(connection)
.tap(() => { debug('connection destroy'); });
}, validate=function () { [native code] }, max=10, min=3, acquireTimeoutMillis=30000, idleTimeoutMillis=10000, reapIntervalMillis=9000, reapInterval=9000, log=false, _count=2, _draining=false, _pendingAcquires=[], _inUseObjects=[domain=null, error=error => {
connection._invalid = true;
debug(`connection error ${error.code || error.message}`);
this.pool.destroy(connection);
}, _eventsCount=1, _maxListeners=undefined, user=dummyuser, database=dummy, port=5432, host=localhost, password=null, binary=false, ssl=false, client_encoding=, replication=undefined, isDomainSocket=false, application_name=undefined, fallback_application_name=undefined, user=dummyuser, database=dummy, port=5432, host=localhost, password=null, replication=undefined, getTypeParser=function () { [native code] }, , , _ending=false, _connecting=false, _connectionError=false, domain=null, newListener=function(eventName) {
if(eventName == 'message') {
self._emitMessage = true;
}
}, connect=function() {
if(self.ssl) {
con.requestSsl();
} else {
con.startup(self.getStartupConf());
}
}, sslconnect=function() {
con.startup(self.getStartupConf());
}, authenticationCleartextPassword=function(msg) {
if (null !== self.password) {
cb(msg);
} else {
pgPass(self.connectionParameters, function(pass){
if (undefined !== pass) {
self.connectionParameters.password = self.password = pass;
}
cb(msg);
});
}
}, authenticationMD5Password=function(msg) {
if (null !== self.password) {
cb(msg);
} else {
pgPass(self.connectionParameters, function(pass){
if (undefined !== pass) {
self.connectionParameters.password = self.password = pass;
}
cb(msg);
});
}
}, readyForQuery=function() {
var activeQuery = self.activeQuery;
self.activeQuery = null;
self.readyForQuery = true;
self._pulseQueryQueue();
if(activeQuery) {
activeQuery.handleReadyForQuery(con);
}
}, error=function () { [native code] }, end=function () { [native code] }, notice=function(msg) {
self.emit('notice', msg);
}, rowDescription=function(msg) {
self.activeQuery.handleRowDescription(msg);
}, dataRow=function(msg) {
self.activeQuery.handleDataRow(msg);
}, portalSuspended=function(msg) {
self.activeQuery.handlePortalSuspended(con);
}, emptyQuery=function(msg) {
self.activeQuery.handleEmptyQuery(con);
}, commandComplete=function(msg) {
self.activeQuery.handleCommandComplete(msg, con);
}, parseComplete=function(msg) {
if(self.activeQuery.name) {
con.parsedStatements[self.activeQuery.name] = true;
}
}, copyInResponse=function(msg) {
self.activeQuery.handleCopyInResponse(self.connection);
}, copyData=function (msg) {
self.activeQuery.handleCopyData(msg, self.connection);
}, notification=function(msg) {
self.emit('notification', msg);
}, _eventsCount=18, _maxListeners=undefined, connecting=false, _hadError=false, reading=true, onread=function onStreamRead(nread, buf) {
const handle = this;
const stream = this[owner_symbol];
stream[kUpdateTimer]();
if (nread > 0 && !stream.destroyed) {
if (!stream.push(buf)) {
handle.reading = false;
if (!stream.destroyed) {
const err = handle.readStop();
if (err)
stream.destroy(errnoException(err, 'read'));
}
}
return;
}
if (nread === 0) {
return;
}
if (nread !== UV_EOF) {
return stream.destroy(errnoException(nread, 'read'));
}
// defer this until we actually emit end
if (stream._readableState.endEmitted) {
if (stream[kMaybeDestroy])
stream[kMaybeDestroy]();
} else {
if (stream[kMaybeDestroy])
stream.on('end', stream[kMaybeDestroy]);
// push a null to signal the end of data.
// Do it before `maybeDestroy` for correct order of events:
// `end` -> `close`
stream.push(null);
stream.read(0);
}
}, onconnection=null, _parent=null, _host=localhost, objectMode=false, highWaterMark=16384, head=null, tail=null, length=0, length=0, pipes=null, pipesCount=0, flowing=true, ended=false, endEmitted=false, reading=true, sync=false, needReadable=true, emittedReadable=false, readableListening=false, resumeScheduled=false, emitClose=false, destroyed=false, defaultEncoding=utf8, awaitDrain=0, readingMore=false, decoder=null, encoding=null, readable=true, domain=null, end=[function onReadableStreamEnd() {
if (!this.allowHalfOpen) {
this.write = writeAfterFIN;
if (this.writable)
this.end();
}
maybeDestroy(this);
}, function() {
self.emit('end');
}], connect=function() {
if (self._keepAlive) {
self.stream.setKeepAlive(true);
}
self.emit('connect');
}, error=function(error) {
//don't raise ECONNRESET errors - they can & should be ignored
//during disconnect
if(self._ending && error.code == 'ECONNRESET') {
return;
}
self.emit('error', error);
}, close=function() {
self.emit('end');
}, data=function(buff) {
self._reader.addChunk(buff);
var packet = self._reader.read();
while(packet) {
var msg = self.parseMessage(packet);
if(self._emitMessage) {
self.emit('message', msg);
}
self.emit(msg.name, msg);
packet = self._reader.read();
}
}, _eventsCount=5, _maxListeners=undefined, objectMode=false, highWaterMark=16384, finalCalled=false, needDrain=false, ending=false, ended=false, finished=false, destroyed=false, decodeStrings=false, defaultEncoding=utf8, length=0, writing=false, corked=0, sync=false, bufferProcessing=false, onwrite=function () { [native code] }, writecb=null, writelen=0, bufferedRequest=null, lastBufferedRequest=null, pendingcb=0, prefinished=false, errorEmitted=false, emitClose=false, bufferedRequestCount=0, next=null, entry=null, finish=function () { [native code] }, writable=true, allowHalfOpen=false, _sockname=null, _pendingData=null, _pendingEncoding=, server=null, _server=null, _keepAlive=false, lastBuffer=false, lastOffset=0, buffer=null, offset=1, encoding=utf8, , size=1024, 0=81, 1=0, 2=0, 3=0, 4=245, 5=83, 6=69, 7=76, 8=69, 9=67, 10=84, 11=32, 12=34, 13=105, 14=100, 15=34, 16=44, 17=32, 18=34, 19=110, 20=97, 21=109, 22=101, 23=34, 24=44, 25=32, 26=34, 27=100, 28=101, 29=115, 30=99, 31=114, 32=105, 33=112, 34=116, 35=105, 36=111, 37=110, 38=34, 39=44, 40=32, 41=34, 42=99, 43=114, 44=101, 45=97, 46=116, 47=101, 48=100, 49=95, 50=97, 51=116, 52=34, 53=44, 54=32, 55=34, 56=117, 57=112, 58=100, 59=97, 60=116, 61=101, 62=100, 63=95, 64=97, 65=116, 66=34, 67=44, 68=32, 69=34, 70=100, 71=101, 72=108, 73=101, 74=116
Environment
Dialect:
- mysql
- postgres
- sqlite
- mssql
- any Dialect library version: PostgresSQL Database version: 9.6 Sequelize version: 5.8.12 Node Version: 10.13 OS: MacOS 10.14
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
SequelizeValidationError "l'ID User cannot be not null"
You indicated userIdFound as a prop (with the whole user model instance) while calling create method but you need userId prop with just...
Read more >SequelizeValidationError: notNull Violation - lvwd-14
I'm not able to solve this error while doing the social media project app.
Read more >Problem notNull Violation in Sequelize and Associations ...
It seems that Sequelize cannot set idUser in EmailAddresses. It seems that Sequelize cannot connect both models. I hope anyone can help me!...
Read more >Why is Sequelize saying my input is NULL? : r/mysql - Reddit
Does anyone know what sequelize is saying that my post.post_url field is NULL? I am clearly passing it a value just like all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I understand, but I’m using winston as described in the official docs, passing the error object as an argument. This works fine for most types of errors coming from various libraries my application is using. I’m not doing anything special to customize the output, so the conclusion is that this is sequelize’s issue.
@papb Sorry for the wrong information, looks like this doesn’t happen when used with
console.log