Bug in migrations when testing on Django 3.2b1

145 views
Skip to first unread message

Hanne Moa

unread,
Mar 18, 2021, 10:06:51 AM3/18/21
to django-d...@googlegroups.com
I have some migrations that runs/tests fine on Django 3.0 and 3.1, but
not on 3.2b1.

There's a specific app whose migrations fail with:

django.db.migrations.exceptions.NodeNotFoundError: Migration
prefix_app.000N_fooFoo dependencies reference nonexistent parent node
('app', '000M_bar').

Which migration it is varies between runs, and note that the first app
label looks different than the second. Is there some new way to
auto-generate app labels that leads to this?

In INSTALLED_APPS the app in question is by path: "prefix.app". In the
AppConfig, "name" is identical to the path, "prefix.app", while
"label" is "prefix_app". The models do not have an explicit tablename
set and in the database they have been created with
"app_modelnameinlowercase", not "prefix_app_modelnameinlowercase".


HM

Hanne Moa

unread,
Mar 18, 2021, 10:26:23 AM3/18/21
to django-d...@googlegroups.com
Changing AppConfig.name to just "app" leads to ModuleNotFoundError: No
module named 'app'.

Changing the path in INSTALLED_APPS to "prefix.app.apps.AppConfig"
instead leads to the same NodeNotFoundError as before.

Carlton Gibson

unread,
Mar 18, 2021, 10:39:04 AM3/18/21
to Django developers (Contributions to Django itself)
Hi. 

So, first off, thanks for testing!

Initial thoughts: 

* We might need a bit more to be able to reproduce — are you able to narrow down the problem? 
* "Which migration it is varies between runs" — that sounds fun 😀
* "Changing AppConfig.name..." — The AppConfig loading was reworked, it could be that:  https://docs.djangoproject.com/en/dev/releases/3.2/#automatic-appconfig-discovery

Can I ask you to get as close as you can to directions for a reproduce and open a ticket on Trac?

If you can't get to a reproduce, it's still worth opening a ticket with as much info as you can:
  * Maybe someone is able to say "Oh, it's this"
  * Provides info for anyone else hitting this. 

Thanks again! 

Kind Regards,

Carlton

Carlton Gibson

unread,
Mar 18, 2021, 10:44:58 AM3/18/21
to Django developers (Contributions to Django itself)
Looking at the history for the migrations code, the was https://github.com/django/django/commit/110001d0bbbabe2a5b57b14a59bd0e4b71bf2712#diff-e7df880bdc17c719e0332fa0cfbd4eff49bd481f638e34335a6311cfcd0ebc26 recently which adjusted AppConfigStub, so maybe related. 
(You could see if reverting that helps.)

Hanne Moa

unread,
Mar 19, 2021, 3:42:26 AM3/19/21
to django-d...@googlegroups.com
Reverting didn't see to do anything but I'll spread around some breakpoints in 3.1 and 3.2 and compare what happens.

I have another project, on 3.0, that I'm testing with 3.2 with the exact same naming scheme (except every app has a a label in their AppConfig, in the one that fails, not all of them do) and this other project, everything migrates just fine. The failing project started life before migrations existed so there might be some not-upgraded cruft that is the cause.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4424f465-3643-4a39-ac9b-f52bacbe48a8n%40googlegroups.com.

Hanne Moa

unread,
Mar 19, 2021, 5:25:47 AM3/19/21
to django-d...@googlegroups.com
*phew* old cruft indeed. I wasn't using the AppConfigs I *thought* I
was using so no wonder things were flaky.

It might for paranoia's sake be worth mentioning in the upgrade notes
for 3.2 that if you get NodeNotFoundError when running
migrations/database tests on 3.2 to double check the app configs, and
the best way to do that is probably running
"django.apps.apps.app_configs.items()", and compare what the version
you're upgrading from says and what 3.2 returns.
Reply all
Reply to author
Forward
0 new messages