Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
token: ${{ secrets.INFRA_DISPATCH_TOKEN }}
repository: sysblok/sysblok-infra
event-type: deploy
client-payload: '{"service": "sysblokbot"}'
client-payload: '{"service": "sysblokbot-testing"}'
2 changes: 1 addition & 1 deletion .github/workflows/publish_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jobs:
token: ${{ secrets.INFRA_DISPATCH_TOKEN }}
repository: sysblok/sysblok-infra
event-type: deploy
client-payload: '{"service": "sysblokbot"}'
client-payload: '{"service": "sysblokbot-prod"}'
11 changes: 8 additions & 3 deletions src/tg/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ async def _send_to_chat_id_async(
return True
except telegram.error.TelegramError as e:
logger.error(f"Could not send a message to {chat_id}", exc_info=e)
# Captured now: the "except ... as e" binding is cleared by Python
# when its except block exits, and the inner except below rebinds
# its own "e" -- reading e.message after the loop would otherwise
# raise UnboundLocalError once the inner except has fired.
original_error_message = e.message
chat_name = AppContext().db_client.get_chat_name(chat_id)
for error_logs_recipient in self.error_logs_recipients:
try:
Expand All @@ -194,16 +199,16 @@ async def _send_to_chat_id_async(
connect_timeout=SEND_CONNECT_TIMEOUT_SEC,
**kwargs,
)
except telegram.error.TelegramError as e:
except telegram.error.TelegramError as redirect_error:
logger.error(
"Could not redirect unsended message "
f"to error_logs_recipients {error_logs_recipient}",
exc_info=e,
exc_info=redirect_error,
)

# HTML parse error isn't a separate class in Telegram
# So we need to dig into the exception message
if "Can't parse entities" in e.message:
if "Can't parse entities" in original_error_message:
try:
# Try sending the plain-text version
await self.bot.send_message(
Expand Down
Loading