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

[Bug]: JSONDecodeError Expecting value: line 1 column 1 (char 0) #24

Open
1 task done
ahmedesmail07 opened this issue Oct 14, 2023 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@ahmedesmail07
Copy link

What happened?

When attempting to send a notification using the OneSignal SDK, a JSON decoding error is encountered, resulting in the following message: JSONDecodeError: Expecting value: line 1 column 1 (char 0).
This issue occurs consistently when attempting to send a notification using the provided client.send_notification function.
This error has been occurred about 6 times only for the last 30 days.

Snippet of code:

@shared_task(bind=True)
def notify_user(self, id):
    if settings.TEST:
        logger.info("push notification on CircleCi")
        return
    try:
        instance = NotificationModel.objects.get(pk=id)
    except NotificationModel.DoesNotExist:
        logger.info('Notification is not found')
        return
    notification = dict()
    if settings.ONESIGNAL_SANDBOX:
        to = [settings.ONESIGNAL_TEST_PLAYER_ID]
    elif not instance.user.devices.exists():
        logger.info('User {} has not devices attached'.format(instance.user.email))
        return
    else:
        to = list(map(lambda d: d.player_id, instance.user.devices.filter(player_id__isnull=False)))
        if len(to) == 0:
            return
    notification['include_player_ids'] = to
    notification['contents'] = {
        'en': instance.content
    }
    notification['headings'] = {
        'en': instance.title,
    }
    notification['ios_badgeType'] = 'Increase'
    notification['ios_badgeCount'] = 1
    try:
        response = client.send_notification(notification)
    except Exception as e:
        logger.info(f"Error is {e}")
        raise self.retry(max_retries=5, countdown=(30), exc=e)
    return response.body

Steps to reproduce?

1- Error when sedning some notifications for the users.

What did you expect to happen?

I expected all notifications to be sent successfully.

Relevant log output

'<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->\n<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->\n<head>\n<title>Access denied | onesignal.com used Cloudflare to restrict access</title>\n<meta charset="UTF-8" />\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n<meta http-equiv="X-UA-Compatible" content="IE=Edge" />\n<meta name="robots" content="noindex, nofollow" />\n<meta name="viewport" content="width=device-width,initial-scale=1" />\n<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" />\n\n\n<script>\n(function(){if(document.addEventListener&&window.XMLHttpRequest&&JSON&&JSON.stringify){var e=function(a){var c=document.getElementById("error-feedback-survey"),d=document.getElementById("error-feedback-success"),b=new XMLHttpRequest;a={event:...

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ahmedesmail07 ahmedesmail07 added the bug Something isn't working label Oct 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant