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

feat: add a warning in debug mode upon "Call to 'getMe' failed! (401: Unauthorized)" that the bot token is incorrect #561

Closed
janek opened this issue Apr 10, 2024 · 9 comments · Fixed by #574

Comments

@janek
Copy link

janek commented Apr 10, 2024

hi!

I'm trying to deploy my bot and starting with following examples in the docs. I get to the same error in 2-3 ways:

Here's a copy-paste of the error from my local attempt with Docker:

docker run --env-file .env dockerdeno

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Task start deno run --allow-net --allow-env main.ts
error: Uncaught (in promise) GrammyError: Call to 'getMe' failed! (401: Unauthorized)
    return new GrammyError(
           ^
    at toGrammyError (https://deno.land/x/[email protected]/core/error.ts:43:12)
    at ApiClient.callApi (https://deno.land/x/[email protected]/core/client.ts:328:20)
    at async withRetries (https://deno.land/x/[email protected]/bot.ts:660:41)
    at async Bot.init (https://deno.land/x/[email protected]/bot.ts:307:22)
    at async Promise.all (index 0)
    at async Bot.start (https://deno.land/x/[email protected]/bot.ts:439:9)
@roj1512
Copy link
Member

roj1512 commented Apr 10, 2024

Closing per https://t.me/grammyjs/229944.

@roj1512 roj1512 closed this as completed Apr 10, 2024
@janek
Copy link
Author

janek commented Apr 10, 2024

In my case the token was invalid because I accidentally appended a letter. It would have been ideal to get a "Token might be invalid" suggestion in the error, but I should have also figured it out from the 401.

@KnorpelSenf
Copy link
Member

This is already documented at https://grammy.dev/resources/faq#_401-unauthorized

@janek
Copy link
Author

janek commented Apr 29, 2024

@KnorpelSenf agreed, and I missed that - but what I meant now is in code. If it's clear that 401 means error is on the side of the user and token is invalid, then it would be safe and very helpful to put that in the error message (to make it more informative).

@KnorpelSenf
Copy link
Member

That's a really good idea actually

@KnorpelSenf KnorpelSenf reopened this Apr 29, 2024
@KnorpelSenf KnorpelSenf changed the title Call to 'getMe' failed! (401: Unauthorized) when using Docker feat: add a warning in debug mode upon "Call to 'getMe' failed! (401: Unauthorized)" that the bot token is incorrect Apr 29, 2024
@janek
Copy link
Author

janek commented Apr 30, 2024

Nice, I'm glad you like it!

@KnorpelSenf
Copy link
Member

Please review #574 and approve it if these changes work for you

@janek
Copy link
Author

janek commented May 30, 2024

Thank you for adding and merging this, and listing me in contributors! 💟 That's so nice.

I'm sorry I didn't answer sooner, I don't check my GitHub notifications often enough

@KnorpelSenf
Copy link
Member

You're welcome :) No worries!

You can enable email notifications so you don't have to check manually

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

Successfully merging a pull request may close this issue.

3 participants