[Django] #32863: Model.check() crashes on Django 3.2 with invalid app label

15 views
Skip to first unread message

Django

unread,
Jun 18, 2021, 8:36:37 PM6/18/21
to django-...@googlegroups.com
#32863: Model.check() crashes on Django 3.2 with invalid app label
-------------------------------------+-------------------------------------
Reporter: Iuri de | Owner: nobody
Silvio |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I found this issue in `django-cryptography` lib
(https://github.com/georgemarshall/django-cryptography). They have a test
with an invalid `app_label`, I'd expect model check to return `False`, but
it crashes when `DEFAULT_AUTO_FIELD` is not defined, because
`_meta.app_config=None` .

{{{
In [1]: from django.db import models
...: class Foo(models.Model):
...: class Meta:
...: app_label = 'bar'
...:

In [2]: Foo.check()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-2-f17a07bccce5> in <module>
----> 1 Foo.check()

~django/db/models/base.py in check(cls, **kwargs)
1291 *cls._check_ordering(),
1292 *cls._check_constraints(databases),
-> 1293 *cls._check_default_pk(),
1294 ]
1295

~django/db/models/base.py in _check_default_pk(cls)
1307 ) and
1308 not settings.is_overridden('DEFAULT_AUTO_FIELD') and
-> 1309 not
cls._meta.app_config._is_default_auto_field_overridden
1310 ):
1311 return [

AttributeError: 'NoneType' object has no attribute
'_is_default_auto_field_overridden'
}}}

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

Django

unread,
Jun 19, 2021, 10:24:08 AM6/19/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.2
(models, ORM) |
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 Jacob Walls):

* stage: Unreviewed => Accepted


Comment:

Thanks for reporting.

Reproduced at 225d96533a8e05debd402a2bfe566487cc27d95f.
Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.

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

Django

unread,
Jun 21, 2021, 5:20:45 AM6/21/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 3.2
(models, ORM) |
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 Mariusz Felisiak):

* severity: Normal => Release blocker


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

Django

unread,
Jun 21, 2021, 10:33:11 AM6/21/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned

Component: Database layer | Version: 3.2
(models, ORM) |
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 Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


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

Django

unread,
Jun 21, 2021, 11:34:30 AM6/21/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/14549 PR]

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

Django

unread,
Jun 22, 2021, 1:25:37 AM6/22/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* needs_docs: 0 => 1


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

Django

unread,
Jun 22, 2021, 8:38:12 AM6/22/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0


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

Django

unread,
Jun 22, 2021, 2:48:47 PM6/22/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | 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 Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jun 22, 2021, 3:19:52 PM6/22/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: closed

Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | 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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"7a9745fed498f69c46a3ffa5dfaff872e0e1df89" 7a9745fe]:
{{{
#!CommitTicketReference repository=""
revision="7a9745fed498f69c46a3ffa5dfaff872e0e1df89"
Fixed #32863 -- Skipped system check for specifying type of auto-created
primary keys on models with invalid app_label.

Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.

Thanks Iuri de Silvio for the report.
}}}

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

Django

unread,
Jun 22, 2021, 3:20:40 PM6/22/21
to django-...@googlegroups.com
#32863: Model.check() crashes with invalid app label and no explicit
DEFAULT_AUTO_FIELD
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Hasan
| Ramezani
Type: Bug | Status: closed
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | 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
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8b2b627f34797b8d497451350b35d7a5103b016e" 8b2b627f]:
{{{
#!CommitTicketReference repository=""
revision="8b2b627f34797b8d497451350b35d7a5103b016e"
[3.2.x] Fixed #32863 -- Skipped system check for specifying type of auto-
created primary keys on models with invalid app_label.

Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb.

Thanks Iuri de Silvio for the report.

Backport of 7a9745fed498f69c46a3ffa5dfaff872e0e1df89 from main
}}}

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

Reply all
Reply to author
Forward
0 new messages