Opened 8 years ago

Closed 8 years ago

#14715 closed (fixed)

Uninformative ValueError in django/utils/

Reported by: btubbs Owned by: nobody
Component: Uncategorized Version: 1.3-alpha
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Today I was getting this when trying to run a new project for the first time:

Traceback (most recent call last):
  File "/Users/brent.tubbs/envs/bleeding/lib/python2.6/site-packages/django/core/servers/", line 281, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/brent.tubbs/envs/bleeding/lib/python2.6/site-packages/django/contrib/staticfiles/", line 60, in __call__
    response = self.serve(request, self.file_path(environ['PATH_INFO']))
  File "/Users/brent.tubbs/envs/bleeding/lib/python2.6/site-packages/django/core/servers/", line 671, in file_path
    return safe_join(self.media_dir, relative_path)
  File "/Users/brent.tubbs/envs/bleeding/lib/python2.6/site-packages/django/utils/", line 44, in safe_join
    raise ValueError('the joined path is located outside of the base path'
ValueError: the joined path is located outside of the base path component

I was stumped! I thought maybe it was down to me configuring django.contrib.staticfiles incorrectly. I was wrong. It was because I had set MEDIA_ROOT and/or ADMIN_MEDIA_PREFIX to '', since I'm not using those in my project.

Attaching a patch that makes safe_join give a bit more informative error message to make it easier to debug issues like this. With the patch, you'd get something more like this:

ValueError: the joined path (/) is located outside of the base path component (/Users/brent.tubbs/envs/bleeding/lib/python2.6/site-packages/django/contrib/admin/media)

Attachments (1)

helpful_value_error.patch (638 bytes) - added by btubbs 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by btubbs

Attachment: helpful_value_error.patch added

comment:1 Changed 8 years ago by rasca

Note: the ADMIN_MEDIA_PREFIX check has been fixed in r14593

comment:2 Changed 8 years ago by Chris Beaven

Resolution: fixed
Status: newclosed

(In [14699]) Fixes #14715 -- More informative ValueError for safe_join util. Thanks btubbs.

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