3.12.3 introduces a breaking change when using DjangoRedis 4.12.1 #7870
Unanswered
Bradleywboggs
asked this question in
Potential Issue
Replies: 1 comment 1 reply
-
Good example of how even innocuous looking changes have an attached risk. 🙂 - "Hey, PR #7849 for keeping the history as a deque instead of list. Makes sense, right?" ... (not much) time passes ... <unforeseen risks become surfaced> 😑 Anyways, just another data point for erring on the side of keeping code churn to an absolute minimum wherever possible. I'll go ahead and revert this, and likely roll a new release. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
3.12.3 introduces a breaking change when using DjangoRedis 4.12.1
For a request without a cached throttling history, the change in the class
SimpleRateThrottle
,at
rest_framework/throttling.py::124
:self.history = self.cache.get(self.key, deque())
causes a
TypeError
to be raised in the same class in thethrottle_success
method specifically at line 141:self.cache.set(self.key, self.history, self.duration
The root of the problem is that DjangoRedis json-serializes the value before inserting into the cache, but
deques
are not json serializable. So the solution would appear to be to cast the value as a deque onget
and as a list onset
or just keep the history as a list.e.g.
@tomchristie
Beta Was this translation helpful? Give feedback.
All reactions