diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 3f0c881f..eeaeaa40 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -90,6 +90,11 @@ class APIQueueHandler(logging.Handler): def emit(self, record): + # Prevent triggering this function while moulinette + # is being initialized with --debug + if not self.actionsmap or len(request.cookies) == 0: + return + profile = request.params.get("profile", self.actionsmap.default_authentication) authenticator = self.actionsmap.get_authenticator(profile) @@ -484,6 +489,8 @@ class _ActionsMapPlugin(object): try: s_id = authenticator.get_session_cookie()["id"] queue = self.log_queues[s_id] + except MoulinetteAuthenticationError: + pass except KeyError: pass else: diff --git a/test/src/authenticators/dummy.py b/test/src/authenticators/dummy.py index 7590500d..b1eec660 100644 --- a/test/src/authenticators/dummy.py +++ b/test/src/authenticators/dummy.py @@ -61,6 +61,9 @@ class Authenticator(BaseAuthenticator): return {"id": random_ascii()} raise MoulinetteAuthenticationError("unable_authenticate") + if not infos and raise_if_no_session_exists: + raise MoulinetteAuthenticationError("unable_authenticate") + if "id" not in infos: infos["id"] = random_ascii() diff --git a/test/src/authenticators/yoloswag.py b/test/src/authenticators/yoloswag.py index 8607be40..2a549526 100644 --- a/test/src/authenticators/yoloswag.py +++ b/test/src/authenticators/yoloswag.py @@ -61,6 +61,9 @@ class Authenticator(BaseAuthenticator): return {"id": random_ascii()} raise MoulinetteAuthenticationError("unable_authenticate") + if not infos and raise_if_no_session_exists: + raise MoulinetteAuthenticationError("unable_authenticate") + if "id" not in infos: infos["id"] = random_ascii()