#36996: Apps registry public API methods lack input validation
------------------------+------------------------------------------------
Reporter: atdash | Type: Cleanup/optimization
Status: new | Component: Core (Other)
Version: 6.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
------------------------+------------------------------------------------
The Apps class in django.apps.registry accepts arbitrary argument types on
its public API methods. Passing a non-string or empty string produces
confusing errors deep in the call stack rather than clear messages at the
API boundary.
For example, apps.get_app_config(42) raises KeyError: 42 from the dict
lookup inside the method. With validation, it would raise TypeError:
app_label must be a string, not int. at the entry point.
Affected methods: get_app_config(), get_model(), register_model(),
is_installed(), lazy_model_operation().
I can submit a PR that already passed your tests, other than not having
created a ticket first! :)
Nicholas
--
Ticket URL: <
https://code.djangoproject.com/ticket/36996>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.