Opened 3 years ago
Last modified 3 years ago
#33324 closed Uncategorized
Missing static file errors with manifest storage are particularly hard to debug (no error email) — at Version 2
Reported by: | Michael | Owned by: | nobody |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 3.2 |
Severity: | Normal | Keywords: | static manifest storage |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Normally when there is an error, an email is sent about the error. However is there is a missing static file, and django.contrib.staticfiles.storage.ManifestStaticFilesStorage tries to calc the static URL, it falls over in an incredibley hard way to debug. If your error pages require the missing static file, that is even harder.
Please consider sending an error email to the support email address if this kind of error occurs.
Its raised in: contrib/staticfiles/storage.py line 417:
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)
As a temp fix I subclassed the storage:
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage class ManifestStaticFilesWith404Storage(ManifestStaticFilesStorage): """If you have a manifest files error, the page to render the error probably has the same error, and then you can't debug it. This returns the error string so one can see in the rendered html there was a problem """ def stored_name(self, name): try: return super().stored_name(name) except ValueError as e: return f"{name}.could_not_find_static_file_to_calc_manifest_hash"
Change History (2)
comment:1 by , 3 years ago
Summary: | Missing static file errors are particularly hard to debug (no error email) → Missing static file errors with manifest storage are particularly hard to debug (no error email) |
---|
comment:2 by , 3 years ago
Description: | modified (diff) |
---|