← Back to PRs

#8694: Fix Telegram routing when token override omits accountId

by codvik open 2026-02-04 08:53 View on GitHub →
channel: telegram stale
## Summary - Infer Telegram accountId from the token when monitorTelegramProvider is called with a token override and no accountId. - Add a unit test covering the missing-accountId token override scenario. ## Testing - pnpm exec vitest src/telegram/monitor.test.ts <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates `monitorTelegramProvider` to infer a missing `accountId` by scanning configured Telegram accounts and matching the provided token override to each account’s resolved token, then adds a unit test asserting that `createTelegramBot` receives the inferred `accountId`. The change fits into the existing account-selection flow in `src/telegram/accounts.ts`, which already has a default/fallback resolution strategy when `accountId` is omitted; this PR adds a more direct routing step when the caller supplies a token override. <h3>Confidence Score: 4/5</h3> - This PR is likely safe to merge, with a small correctness gap around default-token sources during token→account matching. - Changes are localized and covered by a focused unit test; main remaining concern is that accountId inference may not consider default/env/base token sources if `default` isn’t included in the scanned IDs, leading to fallback routing in some configurations. - src/telegram/monitor.ts <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs