fix(telegram): tolerate out-of-range message timestamps - #948
Merged
ralyodio merged 1 commit intoAug 10, 2026
Merged
Conversation
Prevent malformed Telegram timestamps from crashing event normalization. Preserve valid timestamps and fall back to the Unix epoch for invalid dates, mirroring the landed fixes for discord (profullstack#933) and signal (profullstack#932). - export toBotEvent and compute the Date once - use Number.isNaN(date.getTime()) fallback to new Date(0).toISOString() - add regression coverage for an out-of-range value (Number.NEGATIVE_INFINITY) Verified: packages/bots/telegram builds clean and all 16 tests pass locally (core built first, then telegram: 15 existing + 1 new).
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
This mirrors the landed fixes for discord (#933) and signal (#932): the Telegram integration was the only remaining
packages/bots/*bot whosetoBotEventstill used the unsafenew Date(msg.timestamp).toISOString()(found viagrep -rn "new Date(msg.timestamp).toISOString()").Why it matters
A NaN/Infinity/invalid timestamp from a malformed Telegram payload would throw inside
new Date(...).toISOString()and crash event normalization. Discord and Signal already guard against this; Telegram did not.Validation
corepack pnpm --filter @profullstack/sh1pt-core buildthen--filter @profullstack/sh1pt-bot-telegram build→ cleannpx vitest run packages/bots/telegram→ 16 tests pass (15 existing + 1 new regression test)I have enabled "Allow edits from maintainers" so the auto-rebase bot can push (the earlier Telegram attempt #929 failed only because the fork blocked maintainer pushes).