﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22066	KeyError in settings.py leads to baffling 'Unknown command' error	michael.karl.coleman@…	nobody	"In two places in core/management/__init__.py, there is code like this
{{{
    try:
        app_name = get_commands()[name]
    except KeyError:
        raise CommandError(""Unknown command: %r"" % name)
}}}
Unfortunately, KeyErrors from settings.py seem to get caught here, leading to a baffling error message.  The fix would be to just do something like
{{{
    commands = get_commands()
    if name not in commands:
        raise CommandError(""Unknown command: %r"" % name)
    app_name = name
}}}
and let any KeyError from settings.py escape as a backtrace, so that the user can see and fix it directly.

Unfortunately, I don't have time to recreate this and verify that it still exists in HEAD, but just looking at the code, I think it probably does.

This is related to #19257, but I don't believe it's the same bug.
"	Bug	closed	Core (Management commands)	1.6	Normal	duplicate			Unreviewed	0	0	0	0	1	0
