Skip to content

fix(tgbotapi): enforce rich date-time wire contract - #14

Merged
trakhimenok merged 3 commits into
mainfrom
codex/fix-rich-date-time-format
Jul 26, 2026
Merged

fix(tgbotapi): enforce rich date-time wire contract#14
trakhimenok merged 3 commits into
mainfrom
codex/fix-rich-date-time-format

Conversation

@trakhimenok

Copy link
Copy Markdown
Contributor

Production finding

Telegram Bot API 10.2 rejected a Preferans sendRichMessage because date_time_format: "relative" is not valid. The documented format is r|w?[dD]?[tT]?.

The existing validator only required a non-empty string, and its own fixture used the invalid word alias.

Fix

  • validate the complete documented format grammar
  • allow the documented empty format
  • always emit required date_time_format and unix_time fields for RichTextDateTime, including valid zero values
  • keep those variant-only fields absent from other rich-text types
  • replace the invalid fixture and add exhaustive valid/invalid contract tests

Verification

  • direct Telegram A/B probe reproduced the provider rejection for relative and accepted r through rich-message parsing
  • GOWORK=off go test ./... -count=1
  • gofmt -d
  • git diff --check

This branch also contains the previously published Bot API 10.2 implementation from v0.15.5, bringing the release line back onto main.

@trakhimenok
trakhimenok merged commit 665da0d into main Jul 26, 2026
6 checks passed
@trakhimenok
trakhimenok deleted the codex/fix-rich-date-time-format branch July 26, 2026 20:48
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.

1 participant