From 0033c6f0ec1ff326c43f34d60a973cdd6106ed5f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 25 Apr 2020 17:17:45 +0200 Subject: [PATCH 1/2] try/catch around request.get_cookie to catch stupid CookieError --- moulinette/interfaces/api.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 98a95c1d..38a0f98b 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -362,13 +362,24 @@ class _ActionsMapPlugin(object): """ # Retrieve session values - s_id = request.get_cookie("session.id") or random_ascii() + try: + s_id = request.get_cookie("session.id") or random_ascii() + except: + # Super rare case where there are super weird cookie / cache issue + # Previous line throws a CookieError that creates a 500 error ... + # So let's catch it and just use a fresh ID then... + s_id = random_ascii() + try: s_secret = self.secrets[s_id] except KeyError: s_tokens = {} else: - s_tokens = request.get_cookie("session.tokens", secret=s_secret) or {} + try: + s_tokens = request.get_cookie("session.tokens", secret=s_secret) or {} + except: + # Same as for session.id a few lines before + s_tokens = {} s_new_token = random_ascii() try: From 1049a28d6a76e185662d5c38f691cb3ee737159b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 25 Apr 2020 17:29:27 +0200 Subject: [PATCH 2/2] Computer ain't happy because *SPAECIZE* --- moulinette/interfaces/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 38a0f98b..0f5ebaca 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -369,7 +369,7 @@ class _ActionsMapPlugin(object): # Previous line throws a CookieError that creates a 500 error ... # So let's catch it and just use a fresh ID then... s_id = random_ascii() - + try: s_secret = self.secrets[s_id] except KeyError: