[Django] #25510: Putting invalid app name in INSTALLED_APPS makes runserver raise django.core.exceptions.AppRegistryNotReady

10 views
Skip to first unread message

Django

unread,
Oct 6, 2015, 3:40:47 AM10/6/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+--------------------
Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------
If you put an app that can't be imported in INSTALLED_APPS and then run
the {{{runserver}}} command, you get the following exception:

{{{
#!text/x-python-traceback
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 351, in
execute_from_command_line
utility.execute()
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 177, in fetch_command
commands = get_commands()
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 72, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/home/sylvain/.virtualenvs/tmp-
89f7042ac871db52/local/lib/python2.7/site-
packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
}}}

Other commands such as migrate or check correctly raise an ImportError.

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

Django

unread,
Oct 6, 2015, 9:58:19 AM10/6/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
---------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
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 timgraham):

* needs_docs: => 0
* needs_better_patch: => 0
* severity: Normal => Release blocker
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

It's a regression in 1.8.5 bisected to
cc14d51ee8325c82665cb98af4dfe49aab565d52.

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

Django

unread,
Oct 6, 2015, 3:23:35 PM10/6/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
---------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
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
---------------------------------+------------------------------------

Comment (by aaugustin):

I tried writing a test for this but it's hard. The following test fails
when the bug is present and hangs when it's fixed:

{{{
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 4e976d8..fdaaf21 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1385,6 +1385,21 @@ class
ManageRunserverEmptyAllowedHosts(AdminScriptTestCase):
self.assertOutput(err, 'CommandError: You must set
settings.ALLOWED_HOSTS if DEBUG is False.')


+class ManageRunserverNonExistentApp(AdminScriptTestCase):
+ def setUp(self):
+ self.write_settings('settings.py', apps=['no_such_app'])
+
+ def tearDown(self):
+ self.remove_settings('settings.py')
+
+ def test_non_existent_app_raises_import_error(self):
+ """
+ Ensure that a non-existent app raises an ImportError (#25510).
+ """
+ out, err = self.run_manage(['runserver'])
+ self.assertNoOutput(out)
+ self.assertOutput(err, 'ImportError')
+
class ManageTestserver(AdminScriptTestCase):
from django.core.management.commands.testserver import Command as
TestserverCommand

}}}

I don't want to make a test that depends on a `time.sleep(2)` because it
will be slow and flaky. I don't have a suitable way to detect that
`runserver` has forked a child and is running. I can't run `runserver`
without autoreload because that makes the bug go away.

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

Django

unread,
Oct 6, 2015, 3:27:46 PM10/6/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | 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 aaugustin):

* has_patch: 0 => 1
* severity: Release blocker => Normal


Comment:

PR: https://github.com/django/django/pull/5402

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

Django

unread,
Oct 7, 2015, 8:59:45 AM10/7/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by coldmind):

Since another problem was found here
https://code.djangoproject.com/ticket/25523#comment:2 may be it should be
considered as release blocker

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

Django

unread,
Oct 7, 2015, 10:14:02 AM10/7/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | 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 coldmind):

* cc: me@… (added)


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

Django

unread,
Oct 7, 2015, 3:33:03 PM10/7/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by aaugustin):

It can be considered a release blocker if it meets one of these conditions
— from https://docs.djangoproject.com/en/1.8/internals/release-process/:

> Security issues.
> Data loss bugs.
> Crashing bugs.
> Major functionality bugs in newly-introduced features.

If you think it does, feel free to toggle the flag again. (I would find
that advantageous because I could stop caring about this messy problem,
given that other people will pay attention in the run up to the 1.9
release.)

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

Django

unread,
Oct 7, 2015, 5:08:45 PM10/7/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by timgraham):

I thought we should backport to 1.8 since it's a regression in a minor
release.

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

Django

unread,
Oct 15, 2015, 4:09:18 PM10/15/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
------------------------------+------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by aaugustin):

I updated the patch to address the comment on the PR and added release
notes for backporting to 1.8.6.

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

Django

unread,
Oct 17, 2015, 8:26:59 AM10/17/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
-------------------------------------+-------------------------------------

Reporter: sephii | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.8
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 timgraham):

* stage: Accepted => Ready for checkin


Comment:

Pending minor comment on the PR.

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

Django

unread,
Oct 18, 2015, 4:36:15 AM10/18/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
-------------------------------------+-------------------------------------
Reporter: sephii | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.8
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 Aymeric Augustin <aymeric.augustin@…>):

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


Comment:

In [changeset:"df0a446fd4c864c003e4f941b5b7abd6f10c9427" df0a446f]:
{{{
#!CommitTicketReference repository=""
revision="df0a446fd4c864c003e4f941b5b7abd6f10c9427"
Fixed #25510 -- Allowed runserver to start with incorrect INSTALLED_APPS.

In that case, the content of INSTALLED_APPS will be ignored until it's
fixed and the autoreloader kicks in. I confirmed this behavior manually.
As explained on the ticket it's hard to write a test for this case
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25510#comment:10>

Django

unread,
Oct 19, 2015, 2:42:41 PM10/19/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
-------------------------------------+-------------------------------------
Reporter: sephii | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.8
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
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"9ccb92ad0130c0fc5fec43d3b914b49df688ffa5" 9ccb92a]:
{{{
#!CommitTicketReference repository=""
revision="9ccb92ad0130c0fc5fec43d3b914b49df688ffa5"
[1.8.x] Fixed #25510 -- Allowed runserver to start with incorrect
INSTALLED_APPS.

In that case, the content of INSTALLED_APPS will be ignored until it's
fixed and the autoreloader kicks in. I confirmed this behavior manually.
As explained on the ticket it's hard to write a test for this case

Backport of df0a446f from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25510#comment:11>

Django

unread,
Dec 18, 2015, 7:11:01 PM12/18/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
-------------------------------------+-------------------------------------
Reporter: sephii | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.8
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"24ebf17f04ee0ed157c430ff7d10ec0728abd48e" 24ebf17f]:
{{{
#!CommitTicketReference repository=""
revision="24ebf17f04ee0ed157c430ff7d10ec0728abd48e"
[1.9.x] Fixed #25510 -- Allowed runserver to start with incorrect
INSTALLED_APPS.

In that case, the content of INSTALLED_APPS will be ignored until it's
fixed and the autoreloader kicks in. I confirmed this behavior manually.

As explained on the ticket it's hard to write a test for this case.

Backport of df0a446fd4c864c003e4f941b5b7abd6f10c9427 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25510#comment:12>

Django

unread,
Dec 18, 2015, 7:15:12 PM12/18/15
to django-...@googlegroups.com
#25510: Putting invalid app name in INSTALLED_APPS makes runserver raise
django.core.exceptions.AppRegistryNotReady
-------------------------------------+-------------------------------------
Reporter: sephii | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 1.8
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
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7a59910c377f87ae70754090d9561ace404ca7f5" 7a59910]:
{{{
#!CommitTicketReference repository=""
revision="7a59910c377f87ae70754090d9561ace404ca7f5"
Refs #25510 -- Forwardport of 1.9.1 release note.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25510#comment:13>

Reply all
Reply to author
Forward
0 new messages