Opened 16 months ago

Closed 15 months ago

Last modified 15 months ago

#34821 closed Bug (fixed)

Syncing DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings with STORAGES can mutate user settings.

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: contrib.staticfiles Version: 4.2
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Syncing DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings with STORAGES can mutate user settings. An isolation issue can be observed by running tests in the specific order, e.g.

./runtests.py deprecation staticfiles_tests --shuffle=1352276316 --parallel=1

...

======================================================================
ERROR: test_no_warning_when_staticdir_does_not_exist (staticfiles_tests.test_management.TestInteractiveMessages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/tests/staticfiles_tests/cases.py", line 77, in setUp
    self.run_collectstatic()
  File "/django/tests/staticfiles_tests/cases.py", line 89, in run_collectstatic
    call_command(
  File "/django/django/core/management/__init__.py", line 194, in call_command
    return command.execute(*args, **defaults)
  File "/django/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 126, in collect
    for path, storage in finder.list(self.ignore_patterns):
  File "/django/django/contrib/staticfiles/finders.py", line 266, in list
    for path in utils.get_files(self.storage, ignore_patterns):
  File "/django/django/contrib/staticfiles/utils.py", line 23, in get_files
    directories, files = storage.listdir(location)
  File "/django/django/core/files/storage/base.py", line 148, in listdir
    raise NotImplementedError(
NotImplementedError: subclasses of Storage must provide a listdir() method

======================================================================
FAIL: test_location_empty (staticfiles_tests.test_finders.TestMiscFinder)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/django/django/test/utils.py", line 443, in inner
    return func(*args, **kwargs)
  File "/django/tests/staticfiles_tests/test_finders.py", line 124, in test_location_empty
    with self.assertRaisesMessage(ImproperlyConfigured, msg):
  File "/usr/local/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/django/django/test/testcases.py", line 739, in _assert_raises_or_warns_cm
    with func(expected_exception) as cm:
AssertionError: ImproperlyConfigured not raised


----------------------------------------------------------------------
Ran 203 tests in 3.158s

FAILED (failures=1, errors=69)
Used shuffle seed: 1352276316 (given)
Destroying test database for alias 'default'...

Regression in 6b965c600054f970bdf94017ecf2e0e6e0a4326b (check out #34773).

Change History (7)

comment:1 by Mariusz Felisiak, 16 months ago

Has patch: set

comment:2 by Jacob Walls, 16 months ago

Triage Stage: UnreviewedAccepted

comment:3 by Jacob Walls, 16 months ago

Patch needs improvement: set

comment:4 by Mariusz Felisiak, 16 months ago

Patch needs improvement: unset

comment:5 by Jacob Walls, 16 months ago

Triage Stage: AcceptedReady for checkin

comment:6 by GitHub <noreply@…>, 15 months ago

Resolution: fixed
Status: assignedclosed

In a7c73b9:

Fixed #34821 -- Prevented DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings from mutating the main STORAGES.

Regression in 6b965c600054f970bdf94017ecf2e0e6e0a4326b.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 15 months ago

In 97e8a2af:

[4.2.x] Fixed #34821 -- Prevented DEFAULT_FILE_STORAGE/STATICFILES_STORAGE settings from mutating the main STORAGES.

Regression in 6b965c600054f970bdf94017ecf2e0e6e0a4326b.
Backport of a7c73b944f51d6c92ec876fd7e0a171e7c01657d from main

Note: See TracTickets for help on using tickets.
Back to Top