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: