﻿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
14715	Uninformative ValueError in django/utils/_os.py	btubbs	nobody	"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/basehttp.py"", 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/handlers.py"", 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/basehttp.py"", 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/_os.py"", 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)
}}}"		closed	Uncategorized	1.3-alpha		fixed			Unreviewed	1	0	0	0	0	0
