Skip to content

Fix Bot API method parameter parity gaps - #81

Merged
iamwavecut merged 2 commits into
masterfrom
bot-api-parity-gaps
Jul 5, 2026
Merged

Fix Bot API method parameter parity gaps#81
iamwavecut merged 2 commits into
masterfrom
bot-api-parity-gaps

Conversation

@iamwavecut

@iamwavecut iamwavecut commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR tightens parity with the current official Telegram Bot API method parameter tables and fixes the confirmed gaps found during the comparison.

The comparison used a locally generated api.json snapshot from the official Telegram Bot API page (https://core.telegram.org/bots/api). The parity test also accepts the fields shape used by the JSON spec downloaded in this repository's API Parity workflow, so local official-page checks and CI checks cover the same method-parameter surface.

Gaps found and fixed

  • editMessageText now supports the official rich_message parameter via EditMessageTextConfig.RichMessage.
  • sendPaidMedia now supports the official optional payload parameter via PaidMediaConfig.Payload.
  • setCustomEmojiStickerSetThumbnail now serializes CustomEmojiID as custom_emoji_id instead of the non-official position key.
  • setStickerMaskPosition now serializes MaskPosition as mask_position instead of the non-official keywords key.
  • uploadStickerFile now always uses the official multipart field name sticker for the uploaded sticker file.

Parity test changes

api_parity_test.go now checks method parameters in addition to method presence and type fields. The new check walks the package AST to collect params emitted by params() and file fields emitted by files(), including promoted embedded config methods and named config fields such as Chat ChatConfig.

Existing legacy or compatibility-only extra params are allowlisted so the parity test focuses on actionable drift instead of breaking older public surface area.

Compatibility

No source-level breaking changes are intended:

  • New fields are additive: EditMessageTextConfig.RichMessage and PaidMediaConfig.Payload.
  • Existing constructors and struct names remain unchanged.
  • The wire behavior for previously incorrect parameters is corrected to match the official Bot API. Code that depended on the old non-official wire keys (position for custom emoji thumbnail or keywords for mask position) will now send the official keys.
  • uploadStickerFile now normalizes the multipart file field name to sticker, which is the only official parameter name for that file.

Validation

  • go test ./...
  • go vet ./...
  • go test ./... -run TestAPIParityRegressionFixes
  • go test -tags api_parity -run '^TestAPIParity' -v . with the JSON spec used by CI
  • go test -tags api_parity -run '^TestAPIParity' -v . with a local api.json generated from the official Telegram Bot API page

@iamwavecut
iamwavecut marked this pull request as ready for review July 5, 2026 21:30
@iamwavecut
iamwavecut requested a review from zhuk-kk as a code owner July 5, 2026 21:30
@iamwavecut iamwavecut self-assigned this Jul 5, 2026
@iamwavecut
iamwavecut merged commit 01432b5 into master Jul 5, 2026
2 checks passed
@iamwavecut
iamwavecut deleted the bot-api-parity-gaps branch July 5, 2026 21:34
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