Telegram-Mini-Apps / telegram-apps

Made from scratch TypeScript packages, examples and documentation you will surely need to start developing on Telegram Mini Apps.
https://docs.telegram-mini-apps.com/
MIT License
702 stars 197 forks source link

[Bug]: An error occurred processing the "theme_changed" event from the Telegram application. #466

Closed LWJerri closed 2 months ago

LWJerri commented 2 months ago

Telegram Application

Telegram for Android

Describe the Bug

image

I choose Telegram for Andoird because Sentry detected this error exactly in the Android client. To be honest, out of a thousand times when users opened the app, this error has only appeared 5 times, but it's still annoying. I have contacted people who had this error and they have regular clients, nothing modified.

To Reproduce

Steps to reproduce the behavior:

  1. Just use Telegram application and with some chance you will get this error.

Expected Behavior

Correct handling of the user theme without error.

heyqbnk commented 2 months ago

I am not sure, we will do something with this. Telegram documentation describes this event having values as RGB strings like "#AABBCC". For some reason, the Android client decided to send some negative numbers.

This error may be temporary, so it is better not to pay attention to it. Especially, when only 5 users had it.

I can also add, that this will not work with the Telegram SDK. Knowing, that the Telegram SDK is not checking events' payloads data, I wonder what will happen in the application with such an event

LWJerri commented 2 months ago

@heyqbnk, just checked tgWebAppThemeParams with whom the error occurred and the values look like this:

URLSearchParams {
  '/#tgWebAppData' => 'query_id=AAFll6ogAAAAAGWXqiB5iXZz&user=%7B%22id%22%3A545130789%2C%22first_name%22%3A%22first_name%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22username%22%2C%22language_code%22%3A%22uk%22%2C%22allows_write_to_pm%22%3Atrue%7D&auth_date=date&hash=hash',
  'tgWebAppVersion' => '7.8',
  'tgWebAppPlatform' => 'android',
  'tgWebAppThemeParams' => '{"bg_color":"#212d3b","section_bg_color":"#1d2733","secondary_bg_color":"#151e27","text_color":"#ffffff","hint_color":"#7d8b99","link_color":"#5eabe1","button_color":"#50a8eb","button_text_color":"#ffffff","header_bg_color":"#242d39","accent_text_color":"#64b5ef","section_header_text_color":"#79c4fc","subtitle_text_color":"#7b8790","destructive_text_color":"#ee686f","section_separator_color":"#0d1218"}' }

So it means incoming data from Telegram is correct.

heyqbnk commented 2 months ago

You are sending launch parameters. The problem is not in them. The problem is in the theme_changed event payload.

Which version of the SDK is that? I don't see a custom parser for this event. It should be here.

According to this code, the problem could be some event listener throwing an error

LWJerri commented 2 months ago

You are sending launch parameters. The problem is not in them. The problem is in the theme_changed event payload.

Which version of the SDK is that? I don't see a custom parser for this event. It should be here.

According to this code, the problem could be some event listener throwing an error

Yeah, you're right. I was thinking that maybe the original data is being transferred somehow wrong, because this error occurs just after the application is started.

btw - "@telegram-apps/sdk-react": "1.1.3.