#23238: fix(telegram): account named "default" silently breaks inbound polling
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
#14359: fix: prefer named Telegram account over orphan 'default' in binding...
by itsGustav · 2026-02-12
84.5%
#3186: fix(telegram): sanitize update offset + lock polling
by daxiong888 · 2026-01-28
81.4%
#14488: Fix Telegram default account listing and CLI cache-write usage mapping
by abdulbb · 2026-02-12
80.7%
#8166: fix(telegram): lifecycle fixes for duplicate messages and auto-reco...
by cheenu1092-oss · 2026-02-03
80.2%
#11347: fix: scope Telegram update offset to bot token
by anooprdawar · 2026-02-07
79.7%
#6463: fix(telegram): improve timeout handling and prevent channel exits
by ai-fanatic · 2026-02-01
79.3%
#19615: fix(discord): include default account when sub-accounts are configured
by prue-starfield · 2026-02-18
79.2%
#9734: fix(telegram): correct sender identification for channel messages (...
by divol89 · 2026-02-05
78.3%
#14789: fix: per-account dmPolicy ignored in checkInboundAccessControl
by croll83 · 2026-02-12
78.1%
#16548: fix(telegram): enhance chat_id validation and diagnostics
by tanujbhaud · 2026-02-14
78.0%