Skip to content

fix(telegram): tolerate out-of-range message timestamps - #948

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
NecatiY:fix/telegram-out-of-range-timestamp
Aug 10, 2026
Merged

fix(telegram): tolerate out-of-range message timestamps#948
ralyodio merged 1 commit into
profullstack:masterfrom
NecatiY:fix/telegram-out-of-range-timestamp

Conversation

@NecatiY

@NecatiY NecatiY commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prevent malformed Telegram timestamps from crashing event normalization
  • Preserve valid timestamps and fall back to the Unix epoch for invalid dates
  • Add regression coverage for an out-of-range value

This mirrors the landed fixes for discord (#933) and signal (#932): the Telegram integration was the only remaining packages/bots/* bot whose toBotEvent still used the unsafe new Date(msg.timestamp).toISOString() (found via grep -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 build then --filter @profullstack/sh1pt-bot-telegram build → clean
  • npx vitest run packages/bots/telegram16 tests pass (15 existing + 1 new regression test)
  • git diff --check clean

⚠️ Rebase

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).

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).
@ralyodio
ralyodio merged commit b836264 into profullstack:master Aug 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants