ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang
MIT License
165 stars 24 forks source link

sam.nim(199, 10) `n.mapper.tokens[n.pos].kind == JSMN_OBJECT` assertionDefect #67

Closed Retrodynen closed 2 years ago

Retrodynen commented 2 years ago

Bot randomly starts to crash - change in bot API?

I'm forced to rerun the bot with clean=true to get rid of the message queue, it then works for several more days until the same thing happens. 


Error: unhandled exception: /home/zack/.nimble/pkgs/sam-0.1.17/sam.nim(199, 10) `n.mapper.tokens[n.pos].kind == JSMN_OBJECT`  
Async traceback: 
 /home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(788)                       banner 
 /home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(720)                       multiSubs 
 /home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(802)                       multi 
 /home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(720)                       dispatchstart 
 /med/sync/MiscDocs/mbot/banner.nim(103)                                     tgmain 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/api.nim(1170)        poll 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/pure/asyncdispatch.nim(1961) waitFor 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/pure/asyncdispatch.nim(1653) poll 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/pure/asyncdispatch.nim(1394) runOnce 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/pure/asyncdispatch.nim(234)  processPendingCallbacks 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/pure/asyncmacro.nim(28)      loopNimAsyncContinue 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/api.nim(1164)        loopIter 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/utils.nim(97)        unmarshal 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/utils.nim(176)       toOption 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/utils.nim(99)        unmarshal 
 /home/zack/.nimble/pkgs/telebot-1.0.11/telebot/private/utils.nim(107)       unmarshal 
 /home/zack/.nimble/pkgs/sam-0.1.17/sam.nim(199)                             [] 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/system/assertions.nim(38)    failedAssertImpl 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/system/assertions.nim(28)    raiseAssert 
 /home/zack/.choosenim/toolchains/nim-1.6.0/lib/system/fatal.nim(53)         sysFatal 
Exception message: /home/zack/.nimble/pkgs/sam-0.1.17/sam.nim(199, 10) `n.mapper.tokens[n.pos].kind == JSMN_OBJECT`  
[AssertionDefect]
ba0f3 commented 2 years ago

Can you print r.body before this line to see what server gives? https://github.com/ba0f3/telebot.nim/blob/master/src/telebot/private/utils.nim#L199

Retrodynen commented 2 years ago

Hi!

Will do tomorrow afternoon, am about to head to bed :)

I'll show the output of that and then I'll try to get you a minimal reproduction of the issue too. I made this issue in a bit of a rush, sorry.

Thank you for your work on this library!!


From: Huy Doan @.> To: ba0f3/telebot.nim @.> CC: Retrodynen @.>; Author @.> Date: 3 Dec 2021 00:33:40 Subject: Re: [ba0f3/telebot.nim] sam.nim(199, 10) n.mapper.tokens[n.pos].kind == JSMN_OBJECT assertionDefect (Issue #67)

Can you print r.body before this line to see what server gives? https://github.com/ba0f3/telebot.nim/blob/master/src/telebot/private/utils.nim#L199

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub[https://github.com/ba0f3/telebot.nim/issues/67#issuecomment-985113549], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AQ2C6QABQ7LO7XXSHIUD2IDUPAF6BANCNFSM5JIBOBSQ]. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADsAAAA7CAYAAADFJfKzAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAAkSURBVGiB7cExAQAAAMKg9U9tBn+gAAAAAAAAAAAAAAAAAOA2Np8AAXMIPwYAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/AQ2C6QAPZY5LK37ACXDHSSDUPAF6BA5CNFSM5JIBOBS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHK32HTI.gif]

ba0f3 commented 2 years ago

Thank you!

Retrodynen commented 2 years ago
"message":{"message_id":4930974,"from":{"id":484446095,"is_bot":false,"is_deleted":false,"first_name":"Nathan","last_name":"Smith","username":"Ligmanuts"},"chat":{"id":-1001133642811,"title":"/bant/ International Ra 
ndom - also Charlottes blog/ModP playground/Molochs Slayers appreciation group","username":"bantchan","type":"supergroup"},"date":1638440871,"text":"Badge #696969"}}]} 
/home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(788Error: unhandled exception: /home/zack/.nimble/pkgs/sam-0.1.17/sam.nim(239, 10) `node.mapper.tokens[node.pos].kind == JSMN_STRING`  
Async traceback: 
 /home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(788)                       banner
Retrodynen commented 2 years ago

Weird, it seems it's spanning multiple lines?


{"update_id":30499219, 
"message":{"message_id":4930974,"from":{"id":484446095,"is_bot":false,"is_deleted":false,"first_name":"Nathan","last_name":"Smith","username":"Ligmanuts"},"chat":{"id":-1001133642811,"title":"/bant/ International Ra 
ndom - also Charlottes blog/ModP playground/Molochs Slayers appreciation group","username":"bantchan","type":"supergroup"},"date":1638440871,"text":"Badge #696969"}}]} 
/home/zack/.nimble/pkgs/cligen-1.5.19/cligen.nim(788Error: unhandled exception: /home/zack/.nimble/pkgs/sam-0.1.17/sam.nim(239, 10) `node.mapper.tokens[node.pos].kind == JSMN_STRING` 
ba0f3 commented 2 years ago

looks weird, Is there newline in chat title?

Retrodynen commented 2 years ago

There isn't

ba0f3 commented 2 years ago

the json you give me is invalid

Retrodynen commented 2 years ago

is this an issue with telegram's servers then or?

ba0f3 commented 2 years ago

I dont think it came from telegram server. maybe you was behind a proxy or somthing?

Retrodynen commented 2 years ago

I'm not behind any proxy at all

Can I give you a file of the raw response from getUpdates via Telegram?

-------- Original Message -------- Subject: Re: [ba0f3/telebot.nim] sam.nim(199, 10) n.mapper.tokens[n.pos].kind == JSMN_OBJECT assertionDefect (Issue #67) From: Huy Doan @.> To: ba0f3/telebot.nim @.> Cc: Retrodynen @.>, Author @.> Date: Tue Dec 07 2021 17:16:31 GMT+0000 (GMT)

I dont think it came from telegram server. maybe you was behind a proxy or somthing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ba0f3/telebot.nim/issues/67#issuecomment-988120186, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2C6QFXFE3G2O63TLPAED3UPY6O7ANCNFSM5JIBOBSQ.

ba0f3 commented 2 years ago

yes sure, reach me at @quhng on telegram

ba0f3 commented 2 years ago

I think the result was too large, its a sam's problem.

Try to reduce number of updates per request by set limit parameter in loop or getUpdates proc

Retrodynen commented 2 years ago

I did bot.poll(timeout=300, limit=10) instead of bot.poll(timeout=300), the same error occurs. :(

ba0f3 commented 2 years ago

@Retrodynen please check it again

Retrodynen commented 2 years ago

Will do!

Retrodynen commented 2 years ago
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(788) banner
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) multiSubs
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(802) multi
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) dispatchstart
/home/tgbot/mbot/banner.nim(112) tgmain
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/api.nim(1185) poll
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1961) waitFor
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1653) poll
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1394) runOnce
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(234) processPendingCallbacks
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncmacro.nim(28) loopNimAsyncContinue
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/api.nim(1179) loopIter
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(96) unmarshal
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(195) toOption
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(96) unmarshal
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(209) toOption
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(180) unref
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(106) unmarshal
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/json.nim(517) []
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(246) []
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(234) raiseKeyError
[[reraised from:
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(788) banner
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) multiSubs
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(802) multi
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) dispatchstart
/home/tgbot/mbot/banner.nim(112) tgmain
/home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/api.nim(1185) poll
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1963) waitFor
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncfutures.nim(389) read
]]
Error: unhandled exception: key not found: type
Async traceback:
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(788)                           banner
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764)                           multiSubs
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(802)                           multi
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764)                           dispatchstart
  /home/tgbot/mbot/banner.nim(112)                                                 tgmain
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/api.nim(1185)        poll
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1961)     waitFor
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1653)     poll
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1394)     runOnce
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(234)      processPendingCallbacks
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncmacro.nim(28)          loopNimAsyncContinue
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/api.nim(1179)        loopIter
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(96)        unmarshal
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(195)       toOption
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(96)        unmarshal
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(209)       toOption
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(180)       unref
  /home/tgbot/.nimble/pkgs/telebot-2022.01.01/telebot/private/utils.nim(106)       unmarshal
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/json.nim(517)               []
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(246) []
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(234) raiseKeyError
Exception message: key not found: type
Retrodynen commented 2 years ago

Ok I moved to 2022.01.02 and get:

[[reraised from:
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(788) banner
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) multiSubs
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(802) multi
/home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764) dispatchstart
/home/tgbot/mbot/banner.nim(112) tgmain
/home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/api.nim(1185) poll
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1963) waitFor
/home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncfutures.nim(389) read
]]
Error: unhandled exception: key not found: correct_option_id
Async traceback:
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(788)                           banner
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764)                           multiSubs
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(802)                           multi
  /home/tgbot/.nimble/pkgs/cligen-1.5.19/cligen.nim(764)                           dispatchstart
  /home/tgbot/mbot/banner.nim(112)                                                 tgmain
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/api.nim(1185)        poll
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1961)     waitFor
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1653)     poll
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(1394)     runOnce
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncdispatch.nim(234)      processPendingCallbacks
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/asyncmacro.nim(28)          loopNimAsyncContinue
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/api.nim(1179)        loopIter
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/utils.nim(98)        unmarshal
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/utils.nim(189)       toOption
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/utils.nim(98)        unmarshal
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/utils.nim(189)       toOption
  /home/tgbot/.nimble/pkgs/telebot-2022.01.02/telebot/private/utils.nim(100)       unmarshal
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/json.nim(517)               []
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(246) []
  /home/tgbot/.choosenim/toolchains/nim-1.6.2/lib/pure/collections/tables.nim(234) raiseKeyError
Exception message: key not found: correct_option_id
 [KeyError]
Retrodynen commented 2 years ago

Hi, it seems commit ecb8dc1c895fe67e0739ffba027336dc0a8e750a made my bot unresponsive to any command, The bot runs and I can see it receive commands in the debug output but it doesn't seem to react to the command at all. If I switch back to dbd11a3684cd8d0db4724ca6494365c5f1ec093b it works fine. Any ideas?

ba0f3 commented 2 years ago

Close this issue cuz sam is not being used anymore