[Django] #37113: Don't let cache backends swallow explicit errors in cache arguments

1 view
Skip to first unread message

Django

unread,
May 19, 2026, 10:24:09 PM (2 days ago) May 19
to django-...@googlegroups.com
#37113: Don't let cache backends swallow explicit errors in cache arguments
-----------------------------------------------+--------------------------
Reporter: jodizzle | Owner: jodizzle
Type: Uncategorized | Status: assigned
Component: Core (Cache system) | Version: dev
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 |
-----------------------------------------------+--------------------------
The following [https://docs.djangoproject.com/en/6.0/topics/cache/#cache-
arguments cache arguments]

- `TIMEOUT`
- `OPTIONS['MAX_ENTRIES']`
- `OPTIONS['CULL_FREQUENCY']`

are integer values that are handled by
[https://github.com/django/django/blob/3e4e0db66961a48a080ff3ff91f6c0d954261366/django/core/cache/backends/base.py#L66
`BaseCache`] such that non-integer values are ignored and fallback to the
default. For example:

- If a Django app didn't set a `TIMEOUT` for the caching backend, the
cache timeout would be set to `300`, the default;
- If a Django app set a `TIMEOUT` for the caching backend to `0`, the
cache timeout would be set to `0`, as expected;
- If a Django app somehow set a `TIMEOUT` of `'abc'`, the cache timeout
would be set to `300`.

My feeling is that the third behavior is wrong. If any of these settings
can't be parsed by Django as an integer, Django should throw an error to
make it clear to the user that the app is improperly configured.

I'll also note:
- This behavior does not seem to be documented. The cache arguments
section of the documentation mentions the default values, and makes it
fairly clear that the settings are for integers, but it doesn't mention
that inappropriate values are forced to the defaults.
- This behavior does not seem to be tested in the test suite. If the
error swallowing logic is removed, the test suite still passes.
--
Ticket URL: <https://code.djangoproject.com/ticket/37113>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 19, 2026, 10:25:20 PM (2 days ago) May 19
to django-...@googlegroups.com
#37113: Don't let cache backends swallow explicit errors in cache arguments
-------------------------------------+-------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Cache system) | Version: dev
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
-------------------------------------+-------------------------------------
Changes (by jodizzle):

* type: Uncategorized => Cleanup/optimization

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

Django

unread,
May 20, 2026, 11:24:23 AM (23 hours ago) May 20
to django-...@googlegroups.com
#37113: Don't let cache backends swallow explicit errors in cache arguments
-------------------------------------+-------------------------------------
Reporter: jodizzle | Owner: jodizzle
Type: | Status: closed
Cleanup/optimization |
Component: Core (Cache system) | Version: dev
Severity: Normal | Resolution:
| needsnewfeatureprocess
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

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

Comment:

I think we need to confirm that folks are experiencing this as an issue to
validate adding a new system check to validate this here is worth it
Can you discuss on the new features board and see if the community is in
favor of this change? https://github.com/django/new-features
--
Ticket URL: <https://code.djangoproject.com/ticket/37113#comment:2>
Reply all
Reply to author
Forward
0 new messages