jgorset/fandjango

Maybe not related to fandjango: user.oauth_token.extend() fails very often

Morpho opened this issue · 5 comments

About 10% of the requests generated by user.oauth_token.extend() fail. I have no clue why exactly they fail. Facebook returns the following:
response = {u'error_code': 1, u'error_msg': u'An unknown error occurred'}

So in models.py line 256 an AttributeError exception is raised, because it cannot parse the response.

  1. components = parse_qs(response)

Do you guys have any clue why Facebook returns that error?

Hi @Morpho,

I haven't had the opportunity to run the latest version in production yet. Have you enabled the migration in your application's settings on Facebook?

Yes everything is enabled. I am using the newest version of the Facebook API, so no more "offline access", new auth dialog, etc. Its just weird that it only fails sometimes, without any reason. I will look further into it and let you know here. Besides of that, your code is VERY stable and runs without any exceptions. I really love it!

Thanks!

If the issue persists, we might consider to catch and ignore the exception until Facebook sorts it out (presuming it's a bug on their side, which seems likely).

And here's a stacktrace:

AttributeError: 'dict' object has no attribute 'split'

Stacktrace (most recent call last):

  File "django/core/handlers/base.py", line 168, in get_response
    receivers = signals.got_request_exception.send(sender=self.__class__, request=request)

  File "fandjango/middleware.py", line 102, in process_request
    user.oauth_token.extend()

  File "fandjango/models.py", line 256, in extend
    components = parse_qs(response)

  File "python2.6/urlparse.py", line 337, in parse_qs
    for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):

  File "python2.6/urlparse.py", line 363, in parse_qsl
    pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]

Thanks guys. I've made some configurations to ignore exceptions raised by extend until Facebook resolves this issue.

$ pip install fandjango --upgrade