-
Notifications
You must be signed in to change notification settings - Fork 298
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
Fix bug #1103 in setting TELEGRAM_WEBHOOK_HOST causing Flood control exceeded
error
#1934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alexintech 👋 Thank you for opening a PR!
Looks like this change disables live setting validation for everything except Twilio, and I'm not sure this would be a good idea. Please see LiveSettingsValidator for more info on live settings validation.
Have you considered removing the second call to setWebhook
here? The first call to setWebhook
is performed on serializer save, so the second call indeed seems to be redundant. Let me know if this makes sense 🙂
Hi, @vadimkerr! Thank you for your attention. Actually, there are three possible calls to the First case (valid webhook URL entered):
Second case (invalid webhook URL entered, for example, https://123.ngrok):
I have considered removing these lines:
Another option I have tried is modifing _check_telegram_webhook_host() adding validation for existing url: url = create_engine_url("/telegram/", override_base=telegram_webhook_host)
bot = Bot(token=live_settings.TELEGRAM_TOKEN)
webhook_info = bot.get_webhook_info()
if webhook_info.url == url:
return
bot.set_webhook(url)
In LiveSettingsValidator I see only Twilio settings use multiple settings to execute validation. Currently when I change a setting value, it validates one setting, and then runs validations for all existing settings. When I update one setting value, basically I'm excepting that only that field and other dependent on it would be validated. |
@vadimkerr @mderynck any ideas? 😄 |
… exceeded` error
@alexintech please see #2100, multiple calls to live setting validation should be fixed there |
# What this PR does Fixes #1103, inspired by #1934. Makes sure that: 1. `LiveSettings.validate_settings` is only called once per update request and not called for any individual LiveSetting instance save. 2. `telegram.Bot.set_webhook` is only called once per request when changing `TELEGRAM_WEBHOOK_HOST`. ## Which issue(s) this PR fixes #1103 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
The issue should be fixed in #2100, so I'm closing this PR. @alexintech thank you for the contribution! |
What this PR does
When
TELEGRAM_WEBHOOK_HOST
sets into database it calls Telegram'ssetWebhook
twice. The first call on field validation goes correctly. But after saving the fieldLiveSettings.validate_settings()
runs, which validates all settings. It calls Telegram'ssetWebhook
again and in that case receivesFlood control exceeded
error from Telegram.I have found that
LiveSettings.validate_settings
has been invented in commit ef37e6a like a replacement for twilio dependent settings.This PR revalidates only updated dependent settings. So it does not flood Telegram API.
Which issue(s) this PR fixes
#1103
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)