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

Fix new JSONField validation. #580

Merged
merged 4 commits into from
Jun 11, 2024
Merged

Conversation

arjunadeltoso
Copy link
Contributor

Description:

Our setup (Django==3.2.25) has an automatic call to full_clean() on all Models in a pre-save signal.

After upgrading from 4.0.0 to 5.4.1 all our new Django Admins lost the ability to login.

We tracked it down to these calls here https://github.com/python-social-auth/social-app-django/blob/5.4.1/social_django/storage.py#L147, creation fails because extra_data is not passed to create, but the field is required not null and not blank and not empty dictionary.

Making it blank-able and null-able will solve the issue.

TestPlan:

Before the fix (any version between 5.3.0 and 5.4.1):

UserSocialAuth.objects.create(user=User.objects.first(), uid=1, provider="test")
[...]
ValidationError: {'extra_data': ['This field cannot be blank.']}

After the fix: the UserSocialAuth instance should be created correctly.

Arjuna Del Toso and others added 2 commits May 28, 2024 15:31
**Description:**

Our setup (Django==3.2.25) has an automatic call to full_clean() on all Models in a pre-save signal.

After upgrading from 4.0.0 to 5.4.1 all our new Django Admins lost the ability to login.

We tracked it down to these calls here https://github.com/python-social-auth/social-app-django/blob/5.4.1/social_django/storage.py#L147, creation fails because `extra_data` is not passed to `create`, but the field is required not null and not blank and not empty dictionary.

Making it blank-able and null-able will solve the issue.

**TestPlan:**

Before the fix (any version between 5.3.0 and 5.4.1):

```
UserSocialAuth.objects.create(user=User.objects.first(), uid=1, provider="test")
[...]
ValidationError: {'extra_data': ['This field cannot be blank.']}
```

After the fix: the UserSocialAuth instance should be created correctly.
social_django/models.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.56%. Comparing base (fb93814) to head (4b1a3c8).
Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #580      +/-   ##
==========================================
- Coverage   91.72%   91.56%   -0.17%     
==========================================
  Files          39       40       +1     
  Lines        1172     1185      +13     
  Branches      144      147       +3     
==========================================
+ Hits         1075     1085      +10     
- Misses         72       73       +1     
- Partials       25       27       +2     
Flag Coverage Δ
unittests 91.56% <100.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nijel nijel merged commit 1c6f853 into python-social-auth:master Jun 11, 2024
8 of 9 checks passed
@nijel
Copy link
Member

nijel commented Jun 11, 2024

Merged, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants