Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django SuspiciousOperation after upgrade to 1.10

Tags:

django

Recently I have upgraded my apps from 1.8 to 1.10 and now I get flooded by this error:

Exception Type: SuspiciousOperation at << VARIOUS_PAGES >>

Exception Value: The request's session was deleted before the request completed. The user may have logged out in a concurrent request, for example.

I can't figure out why this happen but it seems that the session expires prematurely for some strange reason.

like image 609
Mikael Avatar asked Jan 24 '26 15:01

Mikael


1 Answers

I ran into this today. For me, the issue was that the session keys were still in the cache, but the database session had been deleted. The middleware loaded the session via the cache, but when it attempted to write it back to the database, it triggers the DatabaseError (could not update any rows) which the Session then re-raises as UpdateError, which is then caught and raised as a SuspiciousOperation.

In my case, the problem occurred in a testing environment that had the database restored to an older version, removing the database session keys. But the cache wasn't cleared, so users that had visited the test environment, and had a cookie, began receiving 400 errors (SuspiciousOperation).

like image 123
Josh Smeaton Avatar answered Jan 27 '26 03:01

Josh Smeaton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!