Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharing contact info causes error from sam module #68

Closed
hamidb80 opened this issue Dec 30, 2021 · 5 comments
Closed

sharing contact info causes error from sam module #68

hamidb80 opened this issue Dec 30, 2021 · 5 comments

Comments

@hamidb80
Copy link
Contributor

hamidb80 commented Dec 30, 2021

Hey,

I just figured it out that sharing contact info causes node.mapper.tokens[node.pos].kind == JSMN_STRING to fail. [from toStr function in \sam-0.1.17\sam.nim(240, 10)]

the value of node.mapper.tokens[node.pos].kind is JSMN_PRIMITIVE.

tested on telebot 1.0.12
nim 1.6.2

@hamidb80
Copy link
Contributor Author

hamidb80 commented Dec 30, 2021

I think we better use stdlib/json instead of jsmn because it's gotten 20x performace improvement after this

@hamidb80
Copy link
Contributor Author

here's stack trace

>>>  C:\Users\HamidB80\Documents\programming\nim\sam\sam.nim(242, 10) `node.mapper.tokens[node.pos].kind == JSMN_STRING`
Async traceback:
  C:\Users\HamidB80\Documents\programming\nim\azmmonak\src\main.nim(311)                 main
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\api.nim(1183)  poll
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(1961)     waitFor
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(1653)     poll
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(419)      runOnce
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\pure\asyncdispatch.nim(234)      processPendingCallbacks
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\pure\asyncmacro.nim(28)          loopNimAsyncContinue
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\api.nim(1177)  loopIter
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(97)  unmarshal
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(176) toOption
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(97)  unmarshal
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(176) toOption
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(97)  unmarshal
  C:\Users\HamidB80\Documents\programming\nim\telebot\src\telebot\private\utils.nim(180) toOption
  C:\Users\HamidB80\Documents\programming\nim\sam\sam.nim(242)                           toStr
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\system\assertions.nim(38)        failedAssertImpl
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\system\assertions.nim(28)        raiseAssert
  C:\Users\HamidB80\.choosenim\toolchains\nim-1.6.2\lib\system\fatal.nim(53)             sysFatal
Exception message: C:\Users\HamidB80\Documents\programming\nim\sam\sam.nim(242, 10) `node.mapper.tokens[node.pos].kind == JSMN_STRING`    

@hamidb80
Copy link
Contributor Author

hamidb80 commented Dec 30, 2021

actually the logger says the received message is

[
  {
    "update_id": 693909035,
    "message": {
      "message_id": 625,
      "from": {
        "id": 101862091,
        "is_bot": false,
        "first_name": "Hamid",
        "last_name": "Bluri",
        "username": "hamidb80",
        "language_code": "en"
      },
      "chat": {
        "id": 101862091,
        "first_name": "Hamid",
        "last_name": "Bluri",
        "username": "hamidb80",
        "type": "private"
      },
      "date": 1640893781,
      "reply_to_message": {
        "message_id": 624,
        "from": {
          "id": 2004052302,
          "is_bot": true,
          "first_name": "testboybot",
          "username": "mytestbiybot"
        },
        "chat": {
          "id": 101862091,
          "first_name": "Hamid",
          "last_name": "Bluri",
          "username": "hamidb80",
          "type": "private"
        },
        "date": 1640893777,
        "text": "\u0631\u0648\u06cc \u062f\u06a9\u0645\u0647 \u0628\u0632\u0646\u06cc\u062f"
      },
      "contact": {
        "phone_number": "+989100020106",
        "first_name": "Hamid",
        "last_name": "Bluri",
        "user_id": 101862091
      }
    }
  }
]

@hamidb80
Copy link
Contributor Author

here's a small reproducible example:
https://gist.github.com/hamidb80/1e37a2780e2ff18bf906fc19cf2e24d3

@ba0f3
Copy link
Owner

ba0f3 commented Dec 31, 2021

I will migrate to std/json

ba0f3 added a commit that referenced this issue Jan 1, 2022
@hamidb80 hamidb80 closed this as completed Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants