Bug: KeyError 'from' for `User changed from` status webhook message
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 66/100
Research direction
Start in pywa/types/system.py at from_update, where the traceback shows it reads msg["from"]; compare that with the supplied user_changed_user_id webhook, which has from_user_id and system.user_id. Check nearby system update tests and run the relevant test after tracing how this webhook is parsed. Done means the sample message constructs an update without the KeyError and existing system update behavior still passes.
Written by the indexing model from the issue text.
Description
Short summary
WA user id change is being handled as PhoneNumberChange
Steps to reproduce
Got two webhook messages that looked like this:
{
"entry": [
{
"changes": [
{
"field": "'messages'",
"value": "{'messaging_product': 'whatsapp', 'metadata': {'display_phone_number': '5xxxx', 'phone_number_id': '3xxxx'}, 'messages': [{'from_user_id': 'MX.21xxx', 'id': 'wamid.HBxxxx', 'timestamp': '179xxx', 'system': {'body': 'User changed from CO.16xxx to MX.21xxx', 'user_id': 'MX.21xxx', 'previous_user_id': 'CO.16xxxx', 'type': 'user_changed_user_id'}, 'type': 'system'}]}"
}
],
"id": "39xxx"
}
],
"object": "whatsapp_business_account"
}
And pywa thrown a KeyError ([/] Failed to construct update (field=messages))
KeyError: 'from'
File "pywa/server.py", line 405, in _call_handlers
].from_update(client=self, update=raw_update)
File "pywa/types/system.py", line 71, in from_update
wa_id=msg["from"],
Expected behavior
No response
Logs / Traceback
No response
pywa version
{"label" => "4.x (current)"}
Python version
No response
OS
No response
Minimal reproduction
No response
Additional context
No response
- Dominant language
- Python
- Stars
- 598
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from david-lev/pywa
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug question
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
ready-for-agent
Difficulty 1/5 1-3 hours Newbie friendliness 79/100
gregwebs/agent-vm-images#216 ·
Maintainers usually reply within 1 day
-
Layout accepts a step threshold of 0 or less, then in-toto-verify crashes with StopIterationPossibly taken @BahaaMattar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
gcivil-nyu-org/team5-mon-fall26#145 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gcivil-nyu-org/team3-mon-fall26#156 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
antlr/grammars-v4#5220 ·
Maintainers usually reply within 1 day