← Back to PRs

#6891: fix: Telegram health probe should detect webhook delivery errors

by liaosvcaf open 2026-02-02 05:08 View on GitHub →
channel: telegram app: web-ui commands
## Summary Fixes #6889 The web UI health badge always shows "Health OK" (green) even when Telegram (or any channel) is failing. Three independent issues combine to cause this: ### Bug 1: Telegram probe ignores webhook delivery errors `probeTelegram()` calls `getMe` and `getWebhookInfo` but only reads `url` and `has_custom_certificate`. It ignores `pending_update_count`, `last_error_date`, and `last_error_message` -- so the probe returns `ok: true` as long as the bot token is valid, even when messages are not being delivered. ### Bug 2: Health summary `ok` is hardcoded to `true` `getHealthSnapshot()` always returns `{ ok: true, ... }` regardless of channel probe results. The `ok` field is never derived from actual health data. ### Bug 3: Web UI badge only checks WebSocket connectivity The topbar health badge renders based on `state.connected` (WebSocket alive), not channel health. It never fetches or displays probe results. ## Changes ### `src/telegram/probe.ts` - Extended `TelegramProbe.webhook` type with `pendingUpdateCount`, `lastErrorDate`, `lastErrorMessage` - Parse these fields from `getWebhookInfo` response - Mark probe `ok: false` when `last_error_date` is within 10 minutes ### `src/telegram/probe.test.ts` (new) 5 test cases covering normal operation, getMe failure, recent webhook error, stale webhook error, and getWebhookInfo failure. ### `src/commands/health.ts` - Derive `summary.ok` from channel probe results: `false` if any configured channel has a failed probe ### `ui/src/ui/app-render.ts` - Badge shows "Degraded" (no green dot) when `debugHealth.ok === false` - Shows "OK" (green) when healthy, "Offline" when disconnected ### `ui/src/ui/app-gateway.ts` - Fetch health with `probe: true` on WebSocket connect so the badge has real data immediately ## Testing ``` pnpm vitest run src/telegram/probe.test.ts # 5 passed pnpm vitest run src/commands/health.test.ts # 3 passed (no regressions) ```

Most Similar PRs