Query error

After the link was banned, this error was in the bot log.

2020-12-14T19:28:17.819 | CURRENCY: fetching rates
2020-12-14T19:28:18.020 | CURRENCY: fetched rates
2020-12-14T19:28:50.962 !!! ERROR !!! QUERY ERROR !!! 


UPDATE "user" SET "followCheckAt" = ?, "subscribedAt" = ? WHERE "userId" IN (?) -- PARAMETERS: [1607974130941,null,207850102] 


	 --- NOT NULL constraint failed: user.subscribedAt


2020-12-14T19:28:50.973 !!! ERROR !!! Possibly Unhandled Rejection at: Promise {


  <rejected> QueryFailedError: SqliteError: NOT NULL constraint failed: user.subscribedAt


      at new QueryFailedError (/app/src/error/QueryFailedError.ts:9:9)


      at BetterSqlite3QueryRunner.<anonymous> (/app/src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts:103:19)


      at step (/app/node_modules/tslib/tslib.js:141:27)


      at Object.next (/app/node_modules/tslib/tslib.js:122:57)


      at fulfilled (/app/node_modules/tslib/tslib.js:112:62)


      at processTicksAndRejections (internal/process/task_queues.js:93:5) {


    query: 'UPDATE "user" SET "followCheckAt" = ?, "subscribedAt" = ? WHERE "userId" IN (?)',


    parameters: [ 1607974130941, NaN, 207850102 ]


  }


} reason: QueryFailedError: SqliteError: NOT NULL constraint failed: user.subscribedAt

Unfortunately, the problem still exists and now some of the alerts just don’t work.
I can not longer test them via Tipistream. Is there another way to test whether the bot recognizes a sub, Donation, etc.

2021-02-08T16:00:42.240 !!! ERROR !!! QUERY ERROR !!! 
UPDATE "user" SET "followCheckAt" = ?, "subscribedAt" = ? WHERE "userId" IN (?) -- PARAMETERS: [1612800042209,null,207850102] 
	 --- NOT NULL constraint failed: user.subscribedAt

2021-02-08T16:00:42.295 !!! ERROR !!! Possibly Unhandled Rejection at: Promise {
  <rejected> QueryFailedError: SqliteError: NOT NULL constraint failed: user.subscribedAt
      at new QueryFailedError (/app/src/error/QueryFailedError.ts:9:9)
      at BetterSqlite3QueryRunner.<anonymous> (/app/src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts:103:19)
      at step (/app/node_modules/tslib/tslib.js:141:27)
      at Object.next (/app/node_modules/tslib/tslib.js:122:57)
      at fulfilled (/app/node_modules/tslib/tslib.js:112:62)
      at processTicksAndRejections (internal/process/task_queues.js:93:5) {
    query: 'UPDATE "user" SET "followCheckAt" = ?, "subscribedAt" = ? WHERE "userId" IN (?)',
    parameters: [ 1612800042209, NaN, 207850102 ]
  }
} reason: QueryFailedError: SqliteError: NOT NULL constraint failed: user.subscribedAt

What do you mean by that? You can test alerts by test alert button.

Also with error, are you able pinpoint when its happening? I cannot find followCheckAt and subscribedAt save in code directly. Also it seems like it is happening only for one user?

Also logs might be helpful.

I am preparing update to enable debug informations per table. I will enable it for all user queries and hopefully we will then see where it is coming from. Thanks for your patience.

Edit: this unfortunately didn’t work as expected. I get to understand where might be issue.

Ok so I found a reason of your query error. I believe it was at first caused by incorrect resub which eventually get fixed although invalid data was kept in DB as SQLite doesn’t care about data validity.

To fix this query error issue:

  • Run npx sqlite3 sogebot.db in your bot folder. You should see similar output below
SQLite version 3.33.0 2020-08-14 13:23:32
Enter ".help" for usage hints.
sqlite>
  • type UPDATE user set subscribedAt=0 WHERE userId=207850102; and press Enter
SQLite version 3.33.0 2020-08-14 13:23:32
Enter ".help" for usage hints.
sqlite> UPDATE user set subscribedAt=0 WHERE userId=207850102;
  • You should not get same error.
1 Like

Thank you so much I’ll try it out

After trying a lot, I made it. Now everything works again.
Thanks c:

1 Like

Cheers, glad we solved it :slight_smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.