You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I'm missing certain files in one of the directories that is sourced by the collectstatic process, the end result is an application image that falls over in the runtime environment with a ValueError that is raised at line 513 in Django's django/contrib/staticfiles/storage.py:
url = self.url(context)
File "/home/pbsorg/.cache/pypoetry/virtualenvs/pbsorg-cRclfdpy-py3.10/lib/python3.10/site-packages/django/templatetags/static.py", line 113, in url
return self.handle_simple(path)
File "/home/pbsorg/.cache/pypoetry/virtualenvs/pbsorg-cRclfdpy-py3.10/lib/python3.10/site-packages/django/templatetags/static.py", line 129, in handle_simple
return staticfiles_storage.url(path)
File "/home/pbsorg/.cache/pypoetry/virtualenvs/pbsorg-cRclfdpy-py3.10/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 203, in url
return self._url(self.stored_name, name, force)
File "/home/pbsorg/.cache/pypoetry/virtualenvs/pbsorg-cRclfdpy-py3.10/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 182, in _url
hashed_name = hashed_name_func(*args)
File "/home/pbsorg/.cache/pypoetry/virtualenvs/pbsorg-cRclfdpy-py3.10/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 513, in stored_name
raise ValueError(
ValueError: Missing staticfiles manifest entry for 'styles/shows-landing.css'
In an attempt to avoid this, I set WHITENOISE_MANIFEST_STRICT to False, because I see that, in the relevant Django code, that flag is checked, and, if True the ValueError that shows up in my stack trace is raised:
def stored_name(self, name):
parsed_name = urlsplit(unquote(name))
clean_name = parsed_name.path.strip()
hash_key = self.hash_key(clean_name)
cache_name = self.hashed_files.get(hash_key)
if cache_name is None:
if self.manifest_strict:
raise ValueError(
"Missing staticfiles manifest entry for '%s'" % clean_name
)
cache_name = self.clean_name(self.hashed_name(name))
unparsed_name = list(parsed_name)
unparsed_name[2] = cache_name
# Special casing for a @font-face hack, like url(myfont.eot?#iefix")
# http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
if "?#" in name and not unparsed_name[3]:
unparsed_name[2] += "?"
return urlunsplit(unparsed_name)
However, it's only checked if cache_name is None.
The explanation offered in Issue 289 doesn't really jibe with what I'm inferring from the code: there seems to be only one point in both the whitenoise and Django codebases where the manifest_strict flag is evaluated in branching logic. Not only that, but I don't see how it's possible that an incomplete (ie. missing a one-to-one mapping of filename to hashed filename) staticfiles.json manifest would be created if the files that are collected during the collectstatic process are all present.
In trying to understand why I'm still seeing this ValueError in stack traces despite having set WHITENOISE_MANIFEST_STRICT to false, I've questioned whether or not I've actually configured Whitenoise correctly. Here's my configuration:
No, I wanted to ask you a question regarding the CompressedManifestStaticFilesStorage class: it seems that by setting WHITENOISE_MANIFEST_STRICT to False, I can successfully collectstatic even when I'm missing some static assets. However, later, when I deploy the application, a ValueError causes the application to fail completely in its deployed environment.
Python Version
3.10
Django Version
4.2
Package Version
6.6.0
Description
If I'm missing certain files in one of the directories that is sourced by the
collectstatic
process, the end result is an application image that falls over in the runtime environment with aValueError
that is raised at line 513 in Django'sdjango/contrib/staticfiles/storage.py
:In an attempt to avoid this, I set
WHITENOISE_MANIFEST_STRICT
toFalse
, because I see that, in the relevant Django code, that flag is checked, and, ifTrue
theValueError
that shows up in my stack trace is raised:However, it's only checked if
cache_name
isNone
.The explanation offered in Issue 289 doesn't really jibe with what I'm inferring from the code: there seems to be only one point in both the whitenoise and Django codebases where the
manifest_strict
flag is evaluated in branching logic. Not only that, but I don't see how it's possible that an incomplete (ie. missing a one-to-one mapping of filename to hashed filename)staticfiles.json
manifest would be created if the files that are collected during thecollectstatic
process are all present.In trying to understand why I'm still seeing this
ValueError
in stack traces despite having setWHITENOISE_MANIFEST_STRICT
to false, I've questioned whether or not I've actually configured Whitenoise correctly. Here's my configuration:Any advice or insight would be appreciated.
The text was updated successfully, but these errors were encountered: