deadlinecode / baileys-bottle

56 stars 40 forks source link

QueryFailedError: SQLITE_ERROR: ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint #16

Closed drauber closed 1 year ago

drauber commented 1 year ago

Describe the bug Randomly the erros is showed on Baileys Logs.

To Reproduce Steps to reproduce the behavior: I can't reproduce it. The has only null values, this is not normal. INSERT INTO "chat"("DBId", "id", "messages", "newJid", "oldJid", "lastMsgTimestamp", "unreadCount", "readOnly", "endOfHistoryTransfer", "ephemeralExpiration", "ephemeralSettingTimestamp", "endOfHistoryTransferType", "conversationTimestamp", "name", "pHash", "notSpam", "archived", "disappearingMode", "unreadMentionCount", "markedAsUnread", "participant", "tcToken", "tcTokenTimestamp", "contactPrimaryIdentityKey", "pinned", "muteEndTime", "wallpaper", "mediaVisibility", "tcTokenSenderTimestamp", "suspended", "terminated", "createdAt", "createdBy", "description", "support", "isParentGroup", "isDefaultSubgroup", "parentGroupId", "displayName", "pnJid", "selfMasked", "mute", "pin", "archive", "dBAuthId") VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1) ON CONFLICT ( "id", "dBAuthId" ) DO UPDATE SET "id" = EXCLUDED."id", "dBAuthId" = EXCLUDED."dBAuthId"

Expected behavior The error log does not show any errors.

Screenshots If applicable, add screenshots to help explain your problem. Error_Bottle

Version (please complete the following information):

Additional context Maybe, this is not related, but i'm losting messages (not received by Baileys or not sending to recipients)

deadlinecode commented 1 year ago

Yeah i've had this bevore with nulls Will need to investigate a bit more :/

PauloAK commented 1 year ago

Having that same issue randomly as well :/ Will investigate as well when I've some time.

ju-li commented 1 year ago

I'm getting this error and the way to reproduce it is to create a group chat.

When a group chat is created, these 3 events are emitted: groups.upsert, chats.upsert, and messages.upsert

The groups.upsert and messages.upsert events seem to be handled correctly. The events' data show up in the groups_metadata and messages tables correctly.

So the error should be coming from how the chats.upsert event is handled. I've no idea what about it is causing the error, though.

Hope this helps

ahmedRSA commented 1 year ago

is there any fix for this? package is completely useless if this doesn't gets fixed.

deadlinecode commented 1 year ago

I think i will have to sort out null values since wa seems to emit those on the event but dbs are not happy with null values especially when upserting (which is kinda odd since it should then just insert but nvm) I will just try catch for now and get to it asap

deadlinecode commented 1 year ago

@drauber @ahmedRSA @PauloAK @ju-li I fucked up while mapping the newChat parameter Should be fixed in the newest hot fix release (https://www.npmjs.com/package/baileys-bottle/v/2.1.1)

I also added a try catch just for safety Please reopen if it still failes