[Django] #23926: Misleading error message provided when custom permission names are too long

47 views
Skip to first unread message

Django

unread,
Nov 27, 2014, 7:29:33 AM11/27/14
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+--------------------
Reporter: Greatlemer | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------
Whilst adding a new custom permission to a model, I accidentally created
one that was too long and instead of being informed the problem was an
overly long name field, the validation error raised complained about the
verbose name of my model being too long.

This was observed in Django 1.7.1 under python 2.7.

I was able to reproduce it by putting the following code in the models.py
of an application listed in INSTALLED_APPS:
{{{
from django.db.models import Model

class Tmp(Model):
class Meta:
permissions = (
(
'can_do_something_long',
'A custom permission name with greater than 50 chars',
),
)
}}}


Then when I ran ./manage.py migrate I got the following error:
{{{
(env)blah> python ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: blah
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table blah_tmp
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 164, in handle
emit_post_migrate_signal(created_models, self.verbosity,
self.interactive, connection.alias)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/sql.py", line 268, in
emit_post_migrate_signal
using=db)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/contrib/auth/management/__init__.py", line 111, in
create_permissions
verbose_name_max_length,
django.core.exceptions.ValidationError: [u'The verbose_name of tmp is
longer than 39 characters']
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23926>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 27, 2014, 8:01:41 AM11/27/14
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------

Reporter: Greatlemer | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.7
Severity: Normal | 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 timgraham):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Nov 28, 2014, 4:17:07 AM11/28/14
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------

Reporter: Greatlemer | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.7
Severity: Normal | 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 shaib):

* cc: shaib (added)


Comment:

This is actually fixed by #8162 which was fixed (only on master) by
cf252dbea. I'm not sure if we should backport.

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:2>

Django

unread,
Nov 28, 2014, 5:05:31 AM11/28/14
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------

Reporter: Greatlemer | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by timgraham):

The message is still misleading in that it references `verbose_name` even
for custom permissions.

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:3>

Django

unread,
Nov 28, 2014, 8:52:01 AM11/28/14
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------

Reporter: Greatlemer | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by shaib):

I'd thought for a second that the fix for #8162 fixed that too, because
the test code included there uses permissions on permissions. I enjoy
ironic recursion like anyone else, but it might be clearer to change that.

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:4>

Django

unread,
Mar 8, 2015, 7:03:10 AM3/8/15
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------
Reporter: Greatlemer | Owner: joeri
Type: Bug | Status: assigned
Component: contrib.auth | Version: 1.7

Severity: Normal | 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 joeri):

* status: new => assigned
* owner: nobody => joeri


--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:5>

Django

unread,
Mar 8, 2015, 7:39:28 AM3/8/15
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------
Reporter: Greatlemer | Owner: joeri
Type: Bug | Status: assigned
Component: contrib.auth | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by joeri):

The error is technically correct but in some cases doesn't point people to
the most obvious cause. The cryptic database error mentioned in #18866
was replaced with the current message. It was an improvement but with
custom permissions, the error is still cryptic.

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:6>

Django

unread,
Mar 8, 2015, 8:46:39 AM3/8/15
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
------------------------------+------------------------------------
Reporter: Greatlemer | Owner: joeri
Type: Bug | Status: assigned
Component: contrib.auth | Version: 1.7

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by joeri):

Added PR https://github.com/django/django/pull/4274

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:7>

Django

unread,
Mar 8, 2015, 9:16:19 AM3/8/15
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
-------------------------------------+-------------------------------------

Reporter: Greatlemer | Owner: joeri
Type: Bug | Status: assigned
Component: contrib.auth | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by erikr):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:8>

Django

unread,
Mar 16, 2015, 12:17:43 PM3/16/15
to django-...@googlegroups.com
#23926: Misleading error message provided when custom permission names are too long
-------------------------------------+-------------------------------------
Reporter: Greatlemer | Owner: joeri
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"0ed20d5cc4bf94646ffd4e4fcbd963b9916039cd" 0ed20d5]:
{{{
#!CommitTicketReference repository=""
revision="0ed20d5cc4bf94646ffd4e4fcbd963b9916039cd"
Fixed #23926 -- Improved validation error for custom permissions that are
too long.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:9>

Reply all
Reply to author
Forward
0 new messages