-
Notifications
You must be signed in to change notification settings - Fork 208
Open
Description
Summary
The InvalidDataError Exception, when logged, outputs multi-line text (which happens to also be JSON) which is not properly handled by things like Google Cloud Log Explorer. This makes filtering logs difficult.
Line 212 in 15cdc60
| raise InvalidDataError(response.text) |
Resolution
- Remove newlines from
response.text. - (Or) Detect that the content is JSON and un-pretty-print it.
Steps to reproduce
Using pyfcm==2.0.4
from pyfcm import FCMNotification
push_service = FCMNotification(
service_account_file="local_creds.json",
project_id="xxx",
)
result = push_service.notify(
fcm_token="cheeseburgers",
notification_title=title,
notification_body=message_body,
)Traceback (most recent call last):
File "/home/dan/xxx/dan-test.py", line 64, in <module>
result = push_service.notify(
File "/home/dan/xxx/venv/lib/python3.10/site-packages/pyfcm/fcm.py", line 67, in notify
return self.parse_response(response)
File "/home/dan/xxx/venv/lib/python3.10/site-packages/pyfcm/baseapi.py", line 212, in parse_response
raise InvalidDataError(response.text)
pyfcm.errors.InvalidDataError: {
"error": {
"code": 400,
"message": "The registration token is not a valid FCM registration token",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
}
]
}
}
Metadata
Metadata
Assignees
Labels
No labels