Error while saving extra_data for new users
I've got AttributeError at /complete/facebook/ just before redirecting newly registered user to LOGIN_REDIRECT_URL: Exception Value: 'str' object has no attribute 'update'
- Request Method: GET
- Request URL: http://appdomain/complete/facebook/?redirect_state=~&code=~&state=~
- Django Version: 1.9
- Python Version: 2.7.6
- Installed Applications:
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'django.contrib.gis',
- 'social.apps.django_app.default',
- 'myapp'
- Installed Middleware:
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'django.middleware.security.SecurityMiddleware']
Traceback:
File ".../social/pipeline/social_auth.py" in load_extra_data
92. social.set_extra_data(extra_data)
File ".../social/storage/django_orm.py" in set_extra_data
16. if super(DjangoUserMixin, self).set_extra_data(extra_data)
File ".../social/storage/base.py" in set_extra_data
85. self.extra_data.update(extra_data)
User and related social auth was created correctly, except extra_data field of UserSocialAuth model (it was empty JSON string). Every next attempt was completed without any errors, updating extra_data field with facebook related data in JSON format.
Error appears again if User and related UserSocialAuth models are removed. Seems like set_extra_data function assumes self.extra_data to be dict, but str given for new users.
My app is default django project appended using PSA documentation guides.
Here is what was happened:
- db engine is PostgreSQL in my project
- migration for JSONField
extra_datasets{}as default value for new rows social.pipeline.social_auth.load_extra_datacallsset_extra_datamethod ofUserMixinset_extra_datareadsextra_dataattribute of newly created model (which contains{}string at this time) and tries to usedict.updatemethod on it.
After appending and not isinstance(self.extra_data, str) to condition on line 84 of social/storage/base.py I was able to fix this issue.
I am facing the same problem. I don't think it reached the master branch, did it?
I made the update and sent a proposal for the fix. Let's see if someone can approve it.
The fix was merged.