[Django] #32716: ManifestStaticFilesStorage.max_post_process_passes = 0 crashes collectstatic

66 views
Skip to first unread message

Django

unread,
May 5, 2021, 8:48:51 AM5/5/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage.max_post_process_passes = 0 crashes
collectstatic
-------------------------------------------+------------------------
Reporter: Markus Bertheau | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
To reproduce:

1. Derive a custom class from ManifestStaticFilesStorage and set
max_post_process_passes to 0:
{{{
class MyManifestStaticFilesStorage(ManifestStaticFilesStorage):
max_post_process_passes = 0

# settings.py
STATICFILES_STORAGE = "MyManifestStaticFilesStorage"

}}}

2. run collectstatic
{{{
File "lib/python3.7/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 188, in handle
collected = self.collect()
File "lib/python3.7/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 128, in collect
for original_path, processed_path, processed in processor:
File "lib/python3.7/site-
packages/django/contrib/staticfiles/storage.py", line 403, in post_process
yield from super().post_process(*args, **kwargs)
File "lib/python3.7/site-
packages/django/contrib/staticfiles/storage.py", line 251, in post_process
if substitutions:
UnboundLocalError: local variable 'substitutions' referenced before
assignment
}}}

The error can also be seen easily in the code:
https://github.com/django/django/blob/a0a5e0f4c83acdfc6eab69754e245354689c7185/django/contrib/staticfiles/storage.py#L246-L257

`subtitutions` is only set if the loop is entered at least once.

(The motivation to set `max_post_process_passes` to 0 is to have Django
not produce invalid CSS as described here:
https://code.djangoproject.com/ticket/21080#comment:19 )

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

Django

unread,
May 5, 2021, 10:44:33 AM5/5/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage.max_post_process_passes = 0 crashes
collectstatic
---------------------------------+--------------------------------------

Reporter: Markus Bertheau | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Markus Bertheau):

An effective workaround is overriding `patterns = ()`. It might not be
worth fixing the `UnboundLocalError`.

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

Django

unread,
May 6, 2021, 12:56:00 AM5/6/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+------------------------------------

Reporter: Markus Bertheau | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* type: Uncategorized => Bug
* component: Uncategorized => contrib.staticfiles
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

I think it's worth fixing.

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

Django

unread,
May 6, 2021, 1:21:01 AM5/6/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+------------------------------------
Reporter: Markus Bertheau | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+------------------------------------

Comment (by kingliar420):

Hi guys,

Can I work on this?

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

Django

unread,
May 6, 2021, 1:25:02 AM5/6/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+------------------------------------
Reporter: Markus Bertheau | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:3 kingliar420]:


> Can I work on this?

Sure there is no need to ask. Please remember that a regression test is
required.

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

Django

unread,
May 6, 2021, 1:37:34 AM5/6/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+-------------------------------------
Reporter: Markus Bertheau | Owner:
| kingliar420
Type: Bug | Status: assigned

Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by kingliar420):

* owner: nobody => kingliar420
* status: new => assigned


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

Django

unread,
May 6, 2021, 4:36:01 AM5/6/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+-------------------------------------
Reporter: Markus Bertheau | Owner:
| kingliar420
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Bertheau):

* cc: Markus Bertheau (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/32716#comment:6>

Django

unread,
Jun 3, 2021, 1:32:44 AM6/3/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+-------------------------------------
Reporter: Markus Bertheau | Owner:
| aryabartar

Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: staticfiles | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by aryabartar):

* cc: aryabartar (added)
* keywords: => staticfiles
* owner: kingliar420 => aryabartar


--
Ticket URL: <https://code.djangoproject.com/ticket/32716#comment:7>

Django

unread,
Jun 5, 2021, 8:55:09 AM6/5/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+-------------------------------------
Reporter: Markus Bertheau | Owner: Arya
| Khaligh

Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution:
Keywords: staticfiles | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Arya Khaligh):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/14493

Submitted pull request in https://github.com/django/django/pull/14493.

--
Ticket URL: <https://code.djangoproject.com/ticket/32716#comment:8>

Django

unread,
Jun 7, 2021, 2:53:46 AM6/7/21
to django-...@googlegroups.com
#32716: ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
-------------------------------------+-------------------------------------
Reporter: Markus Bertheau | Owner: Arya
| Khaligh
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 3.2
Severity: Normal | Resolution: fixed

Keywords: staticfiles | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"651e527f9b3bc93f04ead654ca215d4252e25fb6" 651e527f]:
{{{
#!CommitTicketReference repository=""
revision="651e527f9b3bc93f04ead654ca215d4252e25fb6"
Fixed #32716 -- Fixed ManifestStaticFilesStorage crash when
max_post_process_passes is 0.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32716#comment:9>

Reply all
Reply to author
Forward
0 new messages