Skip to content

Handle missing message context in CallbackButton and deprecate properties#218

Merged
david-lev merged 8 commits into
masterfrom
dev
Jul 16, 2026
Merged

Handle missing message context in CallbackButton and deprecate properties#218
david-lev merged 8 commits into
masterfrom
dev

Conversation

@david-lev

Copy link
Copy Markdown
Owner

No description provided.

WouterDurnez and others added 8 commits July 13, 2026 11:44
WhatsApp does not always include the context field on incoming
template quick-reply button presses (observed in production on Cloud
API webhooks that also carry the new user_id/from_user_id fields).
CallbackButton.from_update and CallbackSelection.from_update index
msg["context"] unconditionally, so such updates raise KeyError:
'context' and are dropped by the server's update constructor — the
handler never fires and, since 200 is returned, Meta never redelivers.

Parse context the same way Message.from_update already does: treat it
as optional and set reply_to_message=None when absent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CallbackSelection only ever parses interactive list_reply payloads,
which always carry the context field — only the button payload type
(template QuickReplyButton clicks) omits it. Revert the defensive
context parsing and synthetic fixture for CallbackSelection, and
document on CallbackButton.reply_to_message (sync and async) that it
is None specifically for template quick-reply clicks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
[callback] treat missing message context as no reply_to_message in template quick-reply
@david-lev
david-lev merged commit 1e70724 into master Jul 16, 2026
36 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