fix(telegram): tolerate out-of-range message timestamps - #947
Conversation
packages/bot/core and packages/bots/core both fail to compile with
TS2345: the finish() callback parameter was typed with a loose
{ type: string; ... } shape, which is not assignable to AIResult
(type must be the literal "result"). Type it as AIResult so the
workspace build (tsc -p tsconfig.json) passes in both trees.
Also fixes packages/bots/signal compile errors in the test file:
- IncomingMessage.groupId widened to string | null | undefined (the
implementation already falls back with ??, so undefined is valid)
- test literal now includes isGroup and drops the unused raw field
toBotEvent called new Date(msg.timestamp).toISOString() with no NaN guard. msg.date from the Telegram API can be absent/undefined (undefined * 1000 = NaN), which threw RangeError: Invalid time value and dropped the message before handlers ran. Mirrors the same fix already shipped in discord (profullstack#919), whatsapp (profullstack#920), signal (profullstack#932) and slack (profullstack#930): fall back to the epoch when the timestamp is invalid. toBotEvent is now exported so it can be tested, matching the pattern in the other bots.
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
3 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
toBotEventinpackages/bots/telegramcallednew Date(msg.timestamp).toISOString()with no NaN guard.msg.datefrom the Telegram API can be absent —undefined * 1000 === NaN— andnew Date(NaN).toISOString()throwsRangeError: Invalid time value, dropping the message before any handler runs.This is the same bug class already fixed in discord (#919), whatsapp (#920), slack (#930) and signal (#932) — telegram was the only bot missed.
Fix
toBotEventis now exported so it can be tested, matching the pattern in the other bots.Verification
falls back when Telegram provides an out-of-range timestamp(16 tests pass in the package)tsc -p tsconfig.jsonclean