fix(telegram): tolerate out-of-range message timestamps - #947
Open
NecatiY wants to merge 2 commits into
Open
Conversation
added 2 commits
August 9, 2026 13:03
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: |
1 similar comment
|
🤖 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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