[Django] #35477: Django 5.1a1 - unexpected error message

33 views
Skip to first unread message

Django

unread,
May 24, 2024, 1:21:50 AM5/24/24
to django-...@googlegroups.com
#35477: Django 5.1a1 - unexpected error message
-----------------------------------------+------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Hi,

I ran Speedy Net's tests with Django 5.1a1. Some tests failed with an
unexpected error messages. These tests passed with Django versions 4.2.13
and 5.0.6.

To run these tests, run `./tests_manage_all_sites_with_all_warnings.sh
test
speedy.core.accounts.tests.test_views.EditProfileCredentialsViewEnglishTestCase
--shuffle --test-all-languages` with `Django==5.1a1` installed. Here are
the error messages:

`'new_password1': ['This password is too short. It must contain at least 8
characters.', 'This field is required.']` (the actual error message
received)
`'new_password1': ['This password is too short. It must contain at least 8
characters.']` (the expected error message)

It looks like the error message `"This field is required."` is unexpected
and doesn't appear with Django versions 4.2.13 and 5.0.6. Notice that this
field was not missing but too short. A similar problem happens when the
new password is too long.
--
Ticket URL: <https://code.djangoproject.com/ticket/35477>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 24, 2024, 1:39:25 AM5/24/24
to django-...@googlegroups.com
#35477: Django 5.1a1 - unexpected error message
-------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by אורי):

* Attachment "Untitled 2024-05-24 a1.png" added.

Django

unread,
May 24, 2024, 1:39:39 AM5/24/24
to django-...@googlegroups.com
#35477: Django 5.1a1 - unexpected error message
-------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by אורי):

* Attachment "Untitled 2024-05-24 a2.png" added.

Django

unread,
May 24, 2024, 1:41:26 AM5/24/24
to django-...@googlegroups.com
#35477: Django 5.1a1 - unexpected error message
-------------------------------+--------------------------------------
Reporter: אורי | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by אורי:

Old description:

> Hi,
>
> I ran Speedy Net's tests with Django 5.1a1. Some tests failed with an
> unexpected error messages. These tests passed with Django versions 4.2.13
> and 5.0.6.
>
> To run these tests, run `./tests_manage_all_sites_with_all_warnings.sh
> test
> speedy.core.accounts.tests.test_views.EditProfileCredentialsViewEnglishTestCase
> --shuffle --test-all-languages` with `Django==5.1a1` installed. Here are
> the error messages:
>
> `'new_password1': ['This password is too short. It must contain at least
> 8 characters.', 'This field is required.']` (the actual error message
> received)
> `'new_password1': ['This password is too short. It must contain at least
> 8 characters.']` (the expected error message)
>
> It looks like the error message `"This field is required."` is unexpected
> and doesn't appear with Django versions 4.2.13 and 5.0.6. Notice that
> this field was not missing but too short. A similar problem happens when
> the new password is too long.

New description:

Hi,

I ran Speedy Net's tests with Django 5.1a1. Some tests failed with an
unexpected error messages. These tests passed with Django versions 4.2.13
and 5.0.6.

To run these tests, run `./tests_manage_all_sites_with_all_warnings.sh
test
speedy.core.accounts.tests.test_views.EditProfileCredentialsViewEnglishTestCase
--shuffle --test-all-languages` with `Django==5.1a1` installed. Here are
the error messages:

`'new_password1': ['This password is too short. It must contain at least 8
characters.', 'This field is required.']` (the actual error message
received)
`'new_password1': ['This password is too short. It must contain at least 8
characters.']` (the expected error message)

It looks like the error message `"This field is required."` is unexpected
and doesn't appear with Django versions 4.2.13 and 5.0.6. Notice that this
field was not missing but too short. A similar problem happens when the
new password is too long.

I confirm the extra error message appears on the site with Django 5.1a1
and I created screenshots which I'm attaching here. The first screenshot I
attached is with Django 5.1a1 and the second one with Django 4.2.13 (and
is the expected error messages).

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35477#comment:1>

Django

unread,
May 24, 2024, 5:33:54 AM5/24/24
to django-...@googlegroups.com
#35477: Django 5.1a1 - unexpected error message
---------------------------------+------------------------------------
Reporter: אורי | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 5.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Sarah Boyce):

* component: Uncategorized => contrib.auth
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug

Comment:

Hi אורי, I spent quite a while with this. Next time please share links to
your tests or code in the ticket.

git bisect confirmed this is a regression in
e626716c28b6286f8cf0f8174077f3d2244f3eb3 (ref #34429)

Here is a test case:


{{{#!diff
diff --git a/tests/auth_tests/test_forms.py
b/tests/auth_tests/test_forms.py
index b44f1edb24..f5e2612bf5 100644
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -3,6 +3,7 @@ import re
import urllib.parse
from unittest import mock

+from django.contrib.auth import password_validation
from django.contrib.auth.forms import (
AdminPasswordChangeForm,
AuthenticationForm,
@@ -865,6 +866,37 @@ class SetPasswordFormTest(TestDataMixin, TestCase):
form.fields[field_name].widget.attrs["autocomplete"],
autocomplete
)

+ @override_settings(
+ AUTH_PASSWORD_VALIDATORS=[
+ {
+ "NAME": (
+
"django.contrib.auth.password_validation.MinimumLengthValidator"
+ ),
+ "OPTIONS": {"min_length": 12},
+ },
+ ]
+ )
+ def test_extra_validation(self):
+ class ModifiedSetPasswordForm(SetPasswordForm):
+ def clean_new_password1(self):
+ new_password = self.cleaned_data["new_password1"]
+
password_validation.validate_password(password=new_password)
+ return new_password
+
+ user = User.objects.get(username="testclient")
+ form = ModifiedSetPasswordForm(
+ user, {"new_password1": "abc", "new_password2": "abc"}
+ )
+ self.assertIs(form.is_valid(), False)
+ self.assertEqual(
+ form["new_password1"].errors,
+ ["This password is too short. It must contain at least 12
characters."],
+ )
+ self.assertEqual(
+ form["new_password2"].errors,
+ ["This password is too short. It must contain at least 12
characters."],
+ )
+

class PasswordChangeFormTest(TestDataMixin, TestCase):
def test_incorrect_password(self):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35477#comment:2>
Reply all
Reply to author
Forward
0 new messages