[Django] #29469: Makemigrations provides misleading error message.

13 views
Skip to first unread message

Django

unread,
Jun 3, 2018, 9:25:50 PM6/3/18
to django-...@googlegroups.com
#29469: Makemigrations provides misleading error message.
---------------------------------------------+------------------------
Reporter: Matthew Schinckel | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
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 |
---------------------------------------------+------------------------
I have a couple of nested apps, or apps that are not available directly in
the top-level namespace.

When you use makemigrations, and pass the full dotted path to this
command, the error message is somewhat misleading:


{{{
App 'integrations.systems.generic.importers' could not be found. Is it in
INSTALLED_APPS?
}}}

In this case, I have that exact string in my INSTALLED_APPS, but
makemigrations is expecting just the app_label. Perhaps we could improve
the error message when dots are detected in the app_label, suggesting how
to fix it: or even look at just the last part of the path?

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

Django

unread,
Jun 3, 2018, 9:28:33 PM6/3/18
to django-...@googlegroups.com
#29469: Makemigrations provides misleading error message.
-----------------------------------+--------------------------------------

Reporter: Matthew Schinckel | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 2.0
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 Matthew Schinckel):

* component: Uncategorized => Migrations


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

Django

unread,
Jun 5, 2018, 5:48:14 AM6/5/18
to django-...@googlegroups.com
#29469: Makemigrations provides misleading error message.
-----------------------------------+--------------------------------------

Reporter: Matthew Schinckel | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 2.0
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
-----------------------------------+--------------------------------------

Comment (by Windson yang):

Maybe you should add an example project?

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

Django

unread,
Jun 7, 2018, 7:17:59 PM6/7/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------

Reporter: Matthew Schinckel | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: 2.0
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 Tim Graham):

* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


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

Django

unread,
Jun 14, 2018, 2:14:28 AM6/14/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: assigned

Component: Migrations | Version: 2.0
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 oliver):

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


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

Django

unread,
Jun 14, 2018, 2:16:30 AM6/14/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: (none)
Type: Bug | Status: new

Component: Migrations | Version: 2.0
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 oliver):

* owner: oliver => (none)
* status: assigned => new


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

Django

unread,
Jun 14, 2018, 9:36:56 PM6/14/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: assigned
Component: Migrations | Version: 2.0
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 oliver):

* status: new => assigned
* owner: (none) => oliver


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

Django

unread,
Jun 14, 2018, 10:12:25 PM6/14/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: assigned
Component: Migrations | Version: 2.0
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 oliver):

Current code generating that error message is as follows when using
makemigraions command.
{{{
# Make sure the app they asked for exists
app_labels = set(app_labels)
bad_app_labels = set()
for app_label in app_labels:
try:
apps.get_app_config(app_label)
except LookupError:
bad_app_labels.add(app_label)
if bad_app_labels:
for app_label in bad_app_labels:
self.stderr.write("App '%s' could not be found. Is it in
INSTALLED_APPS?" % app_label)
sys.exit(2)
}}}

and below is the part that checks the validity of the app name when using
startapp and createproject command

{{{
if not name.isidentifier():
raise CommandError(
"'{name}' is not a valid {app} name. Please make sure the
"
"name is a valid identifier.".format(
name=name,
app=app_or_project,
)
)
}}}


How about using the code validating app name to current code as follows?
https://github.com/django/django/pull/10051

{{{
# Make sure the app they asked for is a valid app name and exist.
app_labels = set(app_labels)
bad_app_labels = set()
for app_label in app_labels:
try:
apps.get_app_config(app_label)
except LookupError:
bad_app_labels.add(app_label)
if bad_app_labels:
for app_label in bad_app_labels:
if not app_label.isidentifier():
self.stderr.write(
"'%s' is not a valid app name. Please make sure
the "
"name is a valid identifire."% app_label
)
else:
self.stderr.write("App '%s' could not be found. Is it
in INSTALLED_APPS?" % app_label)
sys.exit(2)
}}}

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

Django

unread,
Jun 15, 2018, 9:49:56 AM6/15/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: assigned
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

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

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

Django

unread,
Jun 16, 2018, 5:23:18 AM6/16/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: assigned
Component: Migrations | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by oliver):

https://github.com/django/django/pull/10057

I change the target branch to master and add a test.

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

Django

unread,
Jun 16, 2018, 3:19:21 PM6/16/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: closed
Component: Migrations | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

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


Comment:

In [changeset:"78972af367a1da54aa7e539e4b1ffa2b56571e77" 78972af3]:
{{{
#!CommitTicketReference repository=""
revision="78972af367a1da54aa7e539e4b1ffa2b56571e77"
Fixed #29469 -- Added a helpful makemigrations error if app_label contains
dots.
}}}

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

Django

unread,
Jun 16, 2018, 3:21:35 PM6/16/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: closed
Component: Migrations | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

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

In [changeset:"d03b130cbcc629daa5ae767588b2fff41ea1e48a" d03b130c]:
{{{
#!CommitTicketReference repository=""
revision="d03b130cbcc629daa5ae767588b2fff41ea1e48a"
[2.1.x] Fixed #29469 -- Added a helpful makemigrations error if app_label
contains dots.

Backport of 78972af367a1da54aa7e539e4b1ffa2b56571e77 from master
}}}

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

Django

unread,
Jun 20, 2018, 4:10:54 PM6/20/18
to django-...@googlegroups.com
#29469: Misleading makemigrations "App count not be found" error message with
nested apps
-----------------------------------+------------------------------------
Reporter: Matthew Schinckel | Owner: oliver
Type: Bug | Status: closed
Component: Migrations | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

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

In [changeset:"c3c7d15c34d6174ff25a49d7c9a57da140769567" c3c7d15]:
{{{
#!CommitTicketReference repository=""
revision="c3c7d15c34d6174ff25a49d7c9a57da140769567"
Refs #29469 -- Reused get_app_config() error message in makemigrations
error.
}}}

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

Reply all
Reply to author
Forward
0 new messages