Skip to content

[Bug] Unhandled 403 Forbidden exceptions when users block the Telegram Bot #212

Description

@abarghoud

Criticité : 🟢 Faible (Pollution de logs, pas d'impact critique)
Occurrences (sur 28 j) : 3 occurrences

Description of the issue
When a user blocks the SentryGuard Telegram bot, TelegramBotService throws an unhandled exception when attempting to send a test message.
While TelegramService correctly catches these errors and processes them via TelegramFailureHandlerService (which disables the integration gracefully), the test message route (TelegramController.sendTestMessage) bypasses the main service and calls TelegramBotService.sendMessage(...) directly. This results in noisy ERROR level logs caught by the global ExceptionsHandler.

Expected Behavior
Inject TelegramFailureHandlerService into TelegramController and wrap the telegramBotService.sendMessage call in a try/catch block within sendTestMessage. If an error occurs, pass it to the failure handler to reuse the existing logic (like disabling Telegram for that user if the error is 403) and return false.

Logs

403: Forbidden: bot was blocked by the user
Error: 403: Forbidden: bot was blocked by the user
    at Telegram.callApi
    at async TelegramController.sendTestMessage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions