Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32665 closed Bug (fixed)

caches.W002 check does not support tuples in STATICFILES_DIRS

Reported by: Jared Lockhart Owned by: Mariusz Felisiak
Component: Core (System checks) Version: 3.2
Severity: Release blocker Keywords:
Cc: christa Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The caches.W002 check defined here:

https://github.com/django/django/blob/76c0b32f826469320c59709d31e2f2126dd7c505/django/core/checks/caches.py#L22-L55

inspects the values of each entry in STATICFILES_DIRS here:

https://github.com/django/django/blob/76c0b32f826469320c59709d31e2f2126dd7c505/django/core/checks/caches.py#L30-L33

and passes them to pathlib.Path(staticfiles_dir) which expects a string, however according to the documentation each entry in STATICFILES_DIRS may be either a string or a tuple:

https://docs.djangoproject.com/en/3.2/ref/settings/#prefixes-optional

If a STATICFILES_DIRS entry is provided as a tuple, this check fails with:

TypeError: expected str, bytes or os.PathLike object, not tuple

in python3.9/pathlib.py in _parse_args at line 680

Attachments (1)

32665-tests.diff (1.6 KB ) - added by Mariusz Felisiak 4 years ago.
Regression tests.

Download all attachments as: .zip

Change History (7)

comment:1 by Mariusz Felisiak, 4 years ago

Cc: christa added
Component: UncategorizedCore (System checks)
Easy pickings: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Thanks for the report.

Regression in c36075ac1dddfa986340b1a5e15fe48833322372.
Reproduced at 413c15ef2e3d3958fb641a023bc1e2d15fb2b228.

by Mariusz Felisiak, 4 years ago

Attachment: 32665-tests.diff added

Regression tests.

comment:2 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:3 by Mariusz Felisiak, 4 years ago

Has patch: set

comment:4 by Carlton Gibson, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by GitHub <noreply@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 34d1905:

Fixed #32665 -- Fixed caches system check crash when STATICFILES_DIRS is a list of 2-tuples.

Thanks Jared Lockhart for the report.

Regression in c36075ac1dddfa986340b1a5e15fe48833322372.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 1cc2eaf0:

[3.2.x] Fixed #32665 -- Fixed caches system check crash when STATICFILES_DIRS is a list of 2-tuples.

Thanks Jared Lockhart for the report.

Regression in c36075ac1dddfa986340b1a5e15fe48833322372.
Backport of 34d1905712d33e72c76b3a55a4fc24abbd11be6c from main

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