OneSignal / onesignal-python-api

Other
12 stars 6 forks source link

"Incorrect player_id format in include_player_ids (not a valid UUID): " #30

Closed ahmedsafadii closed 5 months ago

ahmedsafadii commented 5 months ago

What happened?

If you try to send notification and there was at least 1 invalid player id, the request fail

Steps to reproduce?

- Install python SDK
- send notification using it
- try to put invalid ids 
- it will not send and stop it

What did you expect to happen?

to get something like

<Response [200 OK]>------{'id': '0c3212d8-ec61-4ff5-bb7f-89f8c3feab0f', 'external_id': None, 'errors': {'invalid_player_ids': ['03cec736-f85b-46a9-878a-f6d01c150483', ]

and send the notification for valid player ids

Relevant log output

Notification error: Status Code: 400
HTTP response headers: HTTPHeaderDict({'Date': 'Tue, 16 Jan 2024 09:57:05 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'x-runtime': '0.021232', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'x-download-options': 'noopen', 'x-permitted-cross-domain-policies': 'none', 'referrer-policy': 'strict-origin-when-cross-origin', 'access-control-allow-origin': '*', 'access-control-allow-headers': 'SDK-Version', 'vary': 'Accept, Origin', 'cache-control': 'no-cache', 'x-request-id': '07e277b8-3d18-40d1-89d1-c5906facfe2d', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=86400', 'CF-Cache-Status': 'DYNAMIC', 'Set-Cookie': '__cf_bm=iHgnWFrQX41EMBTKmR3kDq2F2Sjul6j41InZvfWTxR4-1705399025-1-AV/mA3y72do2qk9KhINubh4j+oL/SCQRdm7D0mY/fIPwDve/JxVLyWKzcFBw035js7AoMqZn8HpI3/u5qkCatZI=; path=/; expires=Tue, 16-Jan-24 10:27:05 GMT; domain=.onesignal.com; HttpOnly; Secure; SameSite=None', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'Server': 'cloudflare', 'CF-RAY': '84657e039dc466c3-AMS'})

HTTP response body: {"errors":["Incorrect player_id format in include_player_ids (not a valid UUID): "]}

Code of Conduct

ahmedesmail07 commented 5 months ago

I was getting sometimes this issue into my backend side where, the returned value from FE was nil Value where it's not a valid UUID for the player, please ensure that the FE is sending the player_id as expected and add a validation for checking if you are receiving the nil from your server side skip it and continue the logic and add a retry method to send the notification for these users, also if you add a method that converting the un valid UUID to be set as a NULL value also will be ok.

ahmedsafadii commented 5 months ago

@ahmedesmail07 Thank you for your note, yes i found the issue it was not NULL issue, it was that there is a record with empty string value which cuz the issue.