From e555bdd42b848558c9410685788e49ae7f54e873 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 8 Feb 2021 22:14:13 +0100 Subject: [PATCH] lib: fix stacktrace for general expressions --- authentik/lib/expression/evaluator.py | 4 ++++ authentik/policies/expression/evaluator.py | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/authentik/lib/expression/evaluator.py b/authentik/lib/expression/evaluator.py index 12121532b..b94fe53c1 100644 --- a/authentik/lib/expression/evaluator.py +++ b/authentik/lib/expression/evaluator.py @@ -98,6 +98,10 @@ class BaseEvaluator: exec(ast_obj, self._globals, _locals) # nosec # noqa result = _locals["result"] except Exception as exc: + # So, this is a bit questionable. Essentially, we are edit the stacktrace + # so the user only sees information relevant to them + # and none of our surrounding error handling + exc.__traceback__ = exc.__traceback__.tb_next self.handle_error(exc, expression_source) raise exc return result diff --git a/authentik/policies/expression/evaluator.py b/authentik/policies/expression/evaluator.py index ccd457ac3..d30be1e06 100644 --- a/authentik/policies/expression/evaluator.py +++ b/authentik/policies/expression/evaluator.py @@ -55,10 +55,6 @@ class PolicyEvaluator(BaseEvaluator): def handle_error(self, exc: Exception, expression_source: str): """Exception Handler""" - # So, this is a bit questionable. Essentially, we are edit the stacktrace - # so the user only sees information relevant to them - # and none of our surrounding error handling - exc.__traceback__ = exc.__traceback__.tb_next raise PolicyException(exc) def evaluate(self, expression_source: str) -> PolicyResult: