gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

[BUG] CastError: Found wrong type for accessHash. expected bigInt but received [object Object]

Open yauhenipakala opened this issue 4 months ago • 1 comments

Get details from private chat:

const chat = await client.getEntity(-1002855850563);

Returns an exception:

CastError: Found wrong type for accessHash. expected bigInt but received [object Object].
If you think this is a mistake please report it.
    at VirtualClass.assertType (myapp/node_modules/telegram/tl/api.js:352:43)
    at VirtualClass.validate (myapp/node_modules/telegram/tl/api.js:298:30)
    at VirtualClass.getBytes (myapp/node_modules/telegram/tl/api.js:359:26)
    at argToBytes (myapp/node_modules/telegram/tl/api.js:113:22)
    at myapp/node_modules/telegram/tl/api.js:385:80
    at Array.map (<anonymous>)
    at VirtualClass.getBytes (myapp/node_modules/telegram/tl/api.js:385:69)
    at new RequestState (myapp/node_modules/telegram/network/RequestState.js:13:29)
    at Object.invoke (myapp/node_modules/telegram/client/users.js:48:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

TypeError: bigNumber.shiftRight is not a function
    at toSignedLittleBuffer (myapp/node_modules/telegram/Helpers.js:123:34)
    at argToBytes (myapp/node_modules/telegram/tl/api.js:88:20)
    at VirtualClass.getBytes (myapp/node_modules/telegram/tl/api.js:415:42)
    at argToBytes (myapp/node_modules/telegram/tl/api.js:113:22)
    at myapp/node_modules/telegram/tl/api.js:385:80
    at Array.map (<anonymous>)
    at VirtualClass.getBytes (myapp/node_modules/telegram/tl/api.js:385:69)
    at new RequestState (myapp/node_modules/telegram/network/RequestState.js:13:29)
    at Object.invoke (myapp/node_modules/telegram/client/users.js:48:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Debug api.js:352

value that throws exception:

Image

Env:

  • gramjs 2.26.22
  • nodejs 22.16.0

python telethon lib works perfectly:

chat = await client.get_entity(-1002855850563)

Returns chat details;

yauhenipakala avatar Aug 20 '25 09:08 yauhenipakala

Hello. Inside this library useed Big-Integer package. There is expected another type

import bigInt from 'big-integer';
...
chat = await client.get_entity(bigInt(-1002855850563))

sleitor avatar Sep 24 '25 17:09 sleitor