Opened 12 years ago

Closed 11 years ago

#19724 closed Bug (fixed)

manage.py app commands enumeration fails silently when MEDIA_URL doesn't end with a slash

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

Description

When the MEDIA_URL setting in settings.py does not contain a forward slash at the end, calling manage.py without arguments will result in only django core commands being displayed, but no application commands (as specified in INSTALLED_APPS) are shown.

This is presumably due to the parsing of the settings.py file failing silently on the incorrect MEDIA_URL setting. Although it is explicitly called out within the settings.py file (within comments above the MEDIA_URL setting), having it fail loudly when running manage.py is potentially a more expected behaviour.

Attachments (1)

19724-1.diff (851 bytes ) - added by Claude Paroz 12 years ago.
Ouptut error message on sys.stderr if settings contain errors

Download all attachments as: .zip

Change History (10)

comment:1 by Aymeric Augustin, 12 years ago

I can reproduce the problem and I think it's caused by:

        try:
            apps = settings.INSTALLED_APPS
        except ImproperlyConfigured:
            # Still useful for commands that do not require functional settings,
            # like startproject or help
            apps = []

in django.core.management.get_commands, as an invalid MEDIA_URL raises ImproperlyConfigured when the settings are first accessed.

comment:2 by Aymeric Augustin, 12 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

by Claude Paroz, 12 years ago

Attachment: 19724-1.diff added

Ouptut error message on sys.stderr if settings contain errors

comment:3 by Claude Paroz, 12 years ago

Has patch: set

comment:4 by Julien Phalip, 12 years ago

Triage Stage: AcceptedReady for checkin

That looks great to me! Just one nitpicky comment: it'd be useful to emphasize the causality between the two statements:

Project settings contain errors: <ERROR>
As a result, only the core Django commands are available.

comment:5 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 40ca99097f34b2180b2afe6d0056cade4c732618:

Fixed #19724 -- Output error when settings are improperly configured

...during retrieval of available management commands.
Thanks Peter Davis for the report and Julien Phalip for the review.

comment:6 by Claude Paroz <claude@…>, 12 years ago

In 2edef932ff4ffc766c7abe18bde2cc77babd8fef:

Revert "Fixed #19724 -- Output error when settings are improperly configured"

This reverts commit 40ca99097f34b2180b2afe6d0056cade4c732618.
Outputting error is not always suitable, for example this shouldn't
happen for the 'startproject' command.

comment:7 by Claude Paroz, 12 years ago

Resolution: fixed
Status: closednew

The patch was not good.
For example, when running django-admin.py startproject, accessing settings.INSTALLED_APPS will always raise ImproperlyConfigured and this is the regular behaviour (no errors should be shown).

comment:8 by Claude Paroz, 12 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:9 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In a098bee1b9fa4df64f3fd72ff5cbae43bf27e539:

Fixed #19724 -- Output note when showing only core management commands

When listing available management commands, only core commands are
listed if settings have any error. This commit adds a note in this
case so errors are not totally silently skipped.
Thanks Peter Davis for the report.

Note: See TracTickets for help on using tickets.
Back to Top