Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCMPushkin assumes that content field is not null. Fails when push format is event_id_only #363

Closed
octopop opened this issue Mar 9, 2024 · 0 comments · Fixed by #362
Closed

Comments

@octopop
Copy link

octopop commented Mar 9, 2024

If the pusher is set with format:'event_id_only' per the spec, no content is necessary and the pusher may omit it for any reason:

The content field from the event, if present. The pusher may omit this if the event had no content or for any other reason.
https://spec.matrix.org/v1.9/push-gateway-api/#post_matrixpushv1notify

With above; Sygnal fails with error below. It needs to check if data["contents"] is not None before attempting to iterate over it.

│ 2024-03-09 06:36:18,785 [1] DEBUG sygnal.http [f54170f3-1882-4626-b3fd-accc51c10842] Sending push to pushkin com.example.myappsynapsenotification for app ID com.example.myappiosynapsenotificatio │
│ 2024-03-09 06:36:18,786 [1] ERROR sygnal.http [f54170f3-1882-4626-b3fd-accc51c10842] Exception whilst dispatching notification.                                                                        │
│ Traceback (most recent call last):                                                                                                                                                                     │
│   File "/usr/local/lib/python3.10/site-packages/sygnal/http.py", line 275, in _handle_dispatch                                                                                                         │
│     result = await pushkin.dispatch_notification(notif, d, context)                                                                                                                                    │
│   File "/usr/local/lib/python3.10/site-packages/sygnal/notifications.py", line 217, in dispatch_notification                                                                                           │
│     return await self._dispatch_notification_unlimited(n, device, context)                                                                                                                             │
│   File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 523, in _dispatch_notification_unlimited                                                                                   │
│     data = GcmPushkin._build_data(n, device, self.api_version)                                                                                                                                         │
│   File "/usr/local/lib/python3.10/site-packages/sygnal/gcmpushkin.py", line 676, in _build_data                                                                                                        │
│     for attr, value in data["content"].items():                                                                                                                                                        │
│ AttributeError: 'NoneType' object has no attribute 'items'
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 a pull request may close this issue.

1 participant