Code

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#21284 closed Bug (fixed)

Errors in the settings.py file result in misleading messages

Reported by: wildfire Owned by: nobody
Component: Core (Management commands) Version: 1.6-beta-1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

If you have an error in your settings.py, Django 1.6 will give an error indicating that whatever command you are attempting to run does not exist.

$ django-admin.py startproject djtest .
$ python manage.py validate
0 errors found

Now edit djtest/settings.py and put the following in the file:

diff -u djtest.orig/settings.py djtest/settings.py
--- djtest.orig/settings.py 2013-10-17 14:18:51.348674346 +0100
+++ djtest/settings.py 2013-10-17 14:20:07.773667472 +0100
@@ -26,6 +26,7 @@

ALLOWED_HOSTS = []


+ENV_FACTOR_STUFF = os.environENV_FACTOR_STUFF?

# Application definition


# (i.e. attempt to get something from the environment)

$ python manage.py validate
Unknown command: 'validate'
Type 'manage.py help' for usage.

$ python manage.py runserver
Unknown command: 'runserver'
Type 'manage.py help' for usage.

etc.

Attachments (0)

Change History (4)

comment:1 Changed 6 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Does this only happen with KeyError, or also with other exceptions? For instance what happens if you put 1/0 in your settings file?

comment:2 Changed 6 months ago by claudep

  • Component changed from Uncategorized to Core (Management commands)
  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted

That issue is specific to KeyError, which is swallowed in fetch_command. But the workaround is trivial (separate get_commands() from getting the index).

comment:3 Changed 6 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 3514bcb251fb623dbd07911e53d417d55934ffa5:

Fixed #21284 -- Prevented KeyError swallowing in fetch_command

Thanks wildfire for the report.

comment:4 Changed 6 months ago by Claude Paroz <claude@…>

In 621fc1f1d74df2d9240dea88b5f7ebdf472bca38:

[1.6.x] Fixed #21284 -- Prevented KeyError swallowing in fetch_command

Thanks wildfire for the report.

Backport of 3514bcb251 from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.