[Django] #29506: Misleading migrate "App 'apps.somethings' does not have migrations." error message with nested apps

12 views
Skip to first unread message

Django

unread,
Jun 18, 2018, 10:58:03 PM6/18/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: master
(Management commands) |
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 |
-------------------------------------+-------------------------------------
If you have a couple of nested apps, or apps that are not available
directly in the top-level namespace and you use migrate command, and pass
the full dotted path to this command, the error message is somewhat
misleading:

{{{
CommandError: App 'apps.somethings' does not have migrations.
}}}

In this case, the somethings app have migrations, but migrate command
expecting just app_label.

And there is the other misleading error message.
If you use migrate command and pass nonexistent app in your INSTALLED_APP,
the error message is somewhat misleading:

{{{
CommandError: App 'nonexistent_app' does not have migrations.
}}}
In this case, the nonexistent_app does not exist, but the error message
make user think that nonexistent app just don't have migrations.

Currently, makemigrations command check for existence and validity of app.
As follows

{{{
# 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:
if '.' in app_label:
self.stderr.write(
"'%s' is not a valid app label. Did you mean
'%s'?" % (
app_label,
app_label.split('.')[-1],
)
)
else:
self.stderr.write("App '%s' could not be found. Is it
in INSTALLED_APPS?" % app_label)
sys.exit(2)
}}}

How about checking that in migrate command?

== This ticket is very similar to
https://code.djangoproject.com/ticket/29469.
But it is about migrate not makemigrations.
Please read this ticket.

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

Django

unread,
Jun 19, 2018, 2:42:38 AM6/19/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
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 oliver):

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

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

Django

unread,
Jun 19, 2018, 2:45:13 AM6/19/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: master
commands) |
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 oliver:

Old description:

New description:

--

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

Django

unread,
Jun 19, 2018, 3:29:10 AM6/19/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Thanks for the report and the proposed patch. I'll suggest a slightly
different approach in an upcoming patch, as I think the fix for #29469 was
not optimal either.

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

Django

unread,
Jun 19, 2018, 3:55:28 AM6/19/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
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 Claude Paroz):

* needs_better_patch: 1 => 0


Comment:

My suggested [https://github.com/django/django/pull/10063 PR].

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

Django

unread,
Jun 20, 2018, 4:10:54 PM6/20/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"c723a1ff8e76aaef227d5af7a57006cc9bfd2fc8" c723a1ff]:
{{{
#!CommitTicketReference repository=""
revision="c723a1ff8e76aaef227d5af7a57006cc9bfd2fc8"
Fixed #29506 -- Added validation for migrate's app_label option.

Thanks MyungSeKyo for the report and the initial patch.
}}}

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

Django

unread,
Jun 20, 2018, 4:10:54 PM6/20/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

In [changeset:"fc266151648da8856dc735058375ed6cc0e636b5" fc266151]:
{{{
#!CommitTicketReference repository=""
revision="fc266151648da8856dc735058375ed6cc0e636b5"
Refs #29506 -- Added validation for squashmigrations' app_label option.
}}}

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

Django

unread,
Jun 20, 2018, 9:13:28 PM6/20/18
to django-...@googlegroups.com
#29506: Misleading migrate "App 'apps.somethings' does not have migrations." error
message with nested apps
-------------------------------------+-------------------------------------
Reporter: oliver | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Core (Management | Version: master
commands) |
Severity: Normal | Resolution: fixed
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 oliver):

Thank you too.
I learned a lot from your code!

Replying to [comment:5 Tim Graham <timograham@…>]:


> In [changeset:"c723a1ff8e76aaef227d5af7a57006cc9bfd2fc8" c723a1ff]:
> {{{
> #!CommitTicketReference repository=""
revision="c723a1ff8e76aaef227d5af7a57006cc9bfd2fc8"
> Fixed #29506 -- Added validation for migrate's app_label option.
>
> Thanks MyungSeKyo for the report and the initial patch.
> }}}

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

Reply all
Reply to author
Forward
0 new messages