← Back to PRs

#23238: fix(telegram): account named "default" silently breaks inbound polling

by anillBhoi open 2026-02-22 04:19 View on GitHub →
channel: telegram channel: whatsapp-web size: M
## Problem When a Telegram account is named `"default"` in a multi-account config, inbound message polling silently fails. Outbound messages continue to work correctly. No errors appear in logs — making this extremely difficult to diagnose. ## Root Cause The account key `"default"` collides with the `DEFAULT_ACCOUNT_ID` sentinel in `resolveDefaultTelegramAccountId`. The function returned early, treating the account as an implicit fallback rather than a real named account. As a result, the polling loop was never properly initialized for it. ## Fix Added an `isExplicitlyConfigured` guard in `resolveDefaultTelegramAccountId` before the sentinel shortcut path. If `"default"` exists as a real configured account in `channels.telegram.accounts`, it is now treated identically to any other named account and polling initializes correctly for it. ## Test Coverage - 4 existing tests pass (no regressions) - 3 new tests added: - resolves `"default"` as a real account when explicitly configured - inbound polling resolves correctly for account named `"default"` - does not break other accounts when one is named `"default"` ## Closes Closes #23123 Also resolves: #4942, #6665, #7327, #8496, #15082 <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixed a subtle bug where explicitly naming a Telegram account `"default"` in multi-account configs would silently break inbound message polling. The root cause was a collision with the `DEFAULT_ACCOUNT_ID` sentinel value in `resolveDefaultTelegramAccountId`, which caused the function to return early, treating the explicitly configured account as an implicit fallback rather than a real named account. - Added `isExplicitlyConfigured` guard in `src/telegram/accounts.ts:61` to check if `"default"` exists as a real configured account before using the sentinel shortcut path - Added 3 new tests to verify the fix handles edge cases correctly - Also includes an unrelated WhatsApp fix in `src/web/inbound/access-control.ts:43-46` that prevents `readChannelAllowFromStore` from being called when `dmPolicy` is `"allowlist"` (avoiding pairing store bypass vulnerability) Both fixes are minimal, well-tested, and address silent failure scenarios that would be difficult to debug in production. <h3>Confidence Score: 5/5</h3> - Safe to merge - minimal changes with comprehensive test coverage addressing silent failure bugs - High confidence due to: (1) focused, surgical fixes that only touch the specific problematic code paths, (2) comprehensive test coverage with 7 new tests covering edge cases and regressions, (3) no breaking changes to existing behavior - only fixes bugs where behavior was already broken, (4) clear code comments explaining the rationale, and (5) both fixes prevent silent failures that would be difficult to diagnose in production - No files require special attention <sub>Last reviewed commit: f844ae6</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs