#19800: fix(telegram): add INFO-level logging at inbound message drop paths
channel: telegram
size: S
Cluster:
Telegram History and Features
## Summary
- **Problem**: When Telegram inbound messages are dropped (access control, empty message, deduplication), the only logging is at verbose level, making it impossible to diagnose why messages are not reaching the agent session.
- **Why it matters**: Users report messages not being dispatched (#19454) but see no errors — silent drops are unacceptable for a messaging platform.
- **What changed**: Added INFO-level structured logging (`{ chatId, senderId, reason }`) at every `return null` path in `buildTelegramMessageContext`, in `processMessage` when context is null, and in `shouldSkipUpdate` with reason discrimination (offset vs dedupe). Added logging in the message handler after skip detection.
- **What did NOT change**: No behavioral changes — only observability improvements. All existing logic paths remain identical.
## Change Type
- [x] Bug fix
## Linked Issue
- Closes #19454
## Testing
- 4 new tests verify logging at drop points (DM disabled, DM not allowed, empty message, group disabled)
- All 475 telegram tests pass
- Quality gates: `pnpm build && pnpm check && pnpm test` ✅
## AI Disclosure
- AI-assisted: Yes (OpenClaw agent)
- Testing level: fully tested locally
- Understanding: confirmed
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR upgrades Telegram inbound message drop logging from verbose/debug level to structured INFO-level `logger.info` calls with discriminated `reason` fields. Every `return null` path in `buildTelegramMessageContext` and the `shouldSkipUpdate` function now emits structured logs including `chatId`, `senderId`, and a specific `reason` string, making it straightforward to diagnose why messages are not reaching the agent session.
- Replaced `logVerbose` and `logInboundDrop` calls in `bot-message-context.ts` with `logger.info` structured logging at all drop points (group-disabled, topic-disabled, group-allowFrom, dm-disabled, dm-not-allowed, empty-message, control-command-unauthorized, no-mention)
- Added reason discrimination (`"offset"` vs `"dedupe"`) in `shouldSkipUpdate` and removed the `shouldLogVerbose()` guard so skip logs are always emitted
- Added logging in `bot-message.ts` and `bot-handlers.ts` at the caller level after context/skip checks
- Two instances of **redundant double-logging** were introduced: `bot-message.ts` logs `"context-rejected"` after `buildTelegramMessageContext` already logged the specific reason, and `bot-handlers.ts` logs after `shouldSkipUpdate` already logged internally. These should be removed to avoid doubling log volume on every drop
- Added 4 new tests and updated existing test mocks to match new logger interface
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge — it only adds observability logging with no behavioral changes, though the double-logging should ideally be cleaned up.
- The changes are observability-only with no behavioral modifications. All existing logic paths remain identical. The two double-logging instances are a minor issue that would increase log noise but not affect correctness. Tests are thorough and cover the key drop paths.
- `src/telegram/bot-message.ts` and `src/telegram/bot-handlers.ts` have redundant double-logging that should be removed.
<sub>Last reviewed commit: f6af682</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#14367: feat(telegram): add message read via inbound message store
by michaelquinlan88 · 2026-02-12
81.0%
#12936: fix(telegram): omit message_thread_id for private DM chats
by omair445 · 2026-02-09
80.3%
#8166: fix(telegram): lifecycle fixes for duplicate messages and auto-reco...
by cheenu1092-oss · 2026-02-03
80.2%
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
80.2%
#7751: Telegram: persist inbound history (SQLite) + add read action
by welttowelt · 2026-02-03
79.5%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
79.5%
#17953: fix(telegram): prevent silent message loss and duplicate messages i...
by zuyan9 · 2026-02-16
79.4%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
79.1%
#11340: Telegram: skip empty message text instead of throwing (#11238)
by lailoo · 2026-02-07
78.9%
#11347: fix: scope Telegram update offset to bot token
by anooprdawar · 2026-02-07
78.2%