#23484: AppConfigStub.name is set to the app-label, which is not the same thing
------------------------------------------------+------------------------
               Reporter:  carljm                |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Migrations            |        Version:  1.7
               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                     |
------------------------------------------------+------------------------
 In investigating #23483, I noticed that `AppConfigStub` (whose `__init__`
 method receives only an app label) passes on this app-label to
 `AppConfig.__init__` as the `app_name` argument.

 This is clearly wrong, as the app label and app name are two different
 things (if not customized, the latter should be the full dotted path, and
 the former the final segment only). In practice it doesn't cause any
 problems, because the app name is used in very few places. It is used to
 construct the default app-label; in the context of `AppConfigStub`, this
 was the cause of #23483, and after the fix for #23483 it isn't used for
 this anymore in the `AppConfigStub` case. And it is used in
 `AppConfig.import_models`, which is overridden by `AppConfigStub` anyway.

 It would seem more robust to pass in `None` when we don't know the actual
 app-name rather than using the app-label as a substitute (in fact, that's
 what `AppConfigStub` used to do prior to c40209). However, this now runs
 afoul of the app-registry's check for duplicate app names.

 Options:

 1. Do nothing, because it's not currently broken. Maybe add a comment
 clarifying that we know `label` technically is the wrong thing to pass in
 here, but it's good enough in practice and we don't have anything better.

 2. Pass `None`, and filter out app-names of `None` in the app registry
 before checking for dupes.

 3. Pass something explicit like `"fake app name for app label %s" %
 label`.

 I think option (2) is overly invasive, given that the fix is just for
 future robustness, not something that's currently broken. I'd probably
 favor (3), but would be fine with (1) too.

 Thoughts?

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.95a9a35d89a60d9bb8c5c54cf4a582ea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to