Skip to content

whatsApp: fix AttributeError crash on messages without forward metadata#1609

Merged
abrignoni merged 1 commit into
mainfrom
fix-whatsapp-forward-decode
Jun 25, 2026
Merged

whatsApp: fix AttributeError crash on messages without forward metadata#1609
abrignoni merged 1 commit into
mainfrom
fix-whatsapp-forward-decode

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

Problem

whatsAppMessages crashed with:

AttributeError: 'NoneType' object has no attribute 'decode'
  whatsApp.py:248  from_forward = f'{decoded_data.get("21").decode("utf-8")}'

Protobuf field 21 (the forwarded-message sender ID) is absent on any message that isn't a forward — i.e. most messages — so .get("21") returns None and .decode() raises, aborting the entire artifact.

Fix

  • Decode field 21 only when it's bytes, else '':
    forward_id = decoded_data.get("21")
    from_forward = forward_id.decode("utf-8") if isinstance(forward_id, bytes) else ''
  • Default field 17 to '' so number_forward shows '' instead of the literal 'None' when absent.

Pre-existing bug (not from the recent conversions). pylint 10.00/10; verified present-bytes / absent / None all handled without crashing.

decoded_data.get('21') (forwarded-message sender ID) is None for any message that
isn't a forward, so .decode('utf-8') raised AttributeError and aborted the whole
whatsAppMessages artifact. Guard it: decode only when the field is bytes, else ''.
Also default field 17 to '' so number_forward shows '' instead of the literal 'None'
when the field is absent.
@abrignoni abrignoni merged commit 30d79c0 into main Jun 25, 2026
1 check passed
@abrignoni abrignoni deleted the fix-whatsapp-forward-decode branch June 25, 2026 03:08
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