[Django] #33324: Missing static file errors are particularly hard to debug (no error email)

30 views
Skip to first unread message

Django

unread,
Nov 26, 2021, 1:43:46 PM11/26/21
to django-...@googlegroups.com
#33324: Missing static file errors are particularly hard to debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: | Status: new
Uncategorized |
Component: | Version: 3.2
contrib.staticfiles | Keywords: static manifest
Severity: Normal | storage
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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
"""
pass
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"
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33324>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 26, 2021, 1:44:18 PM11/26/21
to django-...@googlegroups.com
#33324: Missing static file errors with manifest storage are particularly hard to

debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: static manifest | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/33324#comment:1>

Django

unread,
Nov 26, 2021, 1:46:00 PM11/26/21
to django-...@googlegroups.com
#33324: Missing static file errors with manifest storage are particularly hard to

debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: static manifest | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Michael:

Old description:

New description:

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"
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33324#comment:2>

Django

unread,
Nov 26, 2021, 1:46:17 PM11/26/21
to django-...@googlegroups.com
#33324: Missing static file errors with manifest storage are particularly hard to

debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: static manifest | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Michael:

Old description:

> Normally when there is an error, an email is sent about the error.

> 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"
> }}}

New description:

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"
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33324#comment:3>

Django

unread,
Nov 26, 2021, 2:00:41 PM11/26/21
to django-...@googlegroups.com
#33324: Missing static file errors with manifest storage are particularly hard to

debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: static manifest | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Michael:

Old description:

> Normally when there is an error, an email is sent about the error.

> 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"
> }}}

New description:

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)
}}}

Side note: mange.py sendtestemail is working, so its not an email setup
issue.

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"
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33324#comment:4>

Django

unread,
Nov 30, 2021, 5:23:43 AM11/30/21
to django-...@googlegroups.com
#33324: Missing static file errors with manifest storage are particularly hard to

debug (no error email)
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: static manifest | Triage Stage:
storage | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => needsinfo


Comment:

Hi Michael.

I'm likely being slow here but, I'm struggling to see exactly what the
issue is you're encountering here.

I'm expecting manifest errors to come up during the `collectstatic` run,
rather than in the request-response cycle.
Also, debug error pages are only used when `DEBUG=True`, so exactly when
file names are not hashed.

Can you put a sample project together that shows the issue exactly? — It's
much easier if I can see it in play, rather than trying to guess what
you're seeing.
Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/33324#comment:5>

Reply all
Reply to author
Forward
0 new messages