core: rework base for SkipObject exception to better support control flow exceptions (#10186)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -6,9 +6,9 @@ from django.http import HttpRequest
|
||||
from authentik.core.expression.evaluator import PropertyMappingEvaluator
|
||||
from authentik.core.expression.exceptions import (
|
||||
PropertyMappingExpressionException,
|
||||
SkipObjectException,
|
||||
)
|
||||
from authentik.core.models import PropertyMapping, User
|
||||
from authentik.lib.expression.exceptions import ControlFlowException
|
||||
|
||||
|
||||
class PropertyMappingManager:
|
||||
@ -60,11 +60,7 @@ class PropertyMappingManager:
|
||||
mapping.set_context(user, request, **kwargs)
|
||||
try:
|
||||
value = mapping.evaluate(mapping.model.expression)
|
||||
except SkipObjectException as exc:
|
||||
exc.exc = exc
|
||||
exc.mapping = mapping
|
||||
raise exc from exc
|
||||
except PropertyMappingExpressionException as exc:
|
||||
except (PropertyMappingExpressionException, ControlFlowException) as exc:
|
||||
raise exc from exc
|
||||
except Exception as exc:
|
||||
raise PropertyMappingExpressionException(exc, mapping.model) from exc
|
||||
|
||||
@ -9,9 +9,9 @@ from structlog.stdlib import get_logger
|
||||
|
||||
from authentik.core.expression.exceptions import (
|
||||
PropertyMappingExpressionException,
|
||||
SkipObjectException,
|
||||
)
|
||||
from authentik.events.models import Event, EventAction
|
||||
from authentik.lib.expression.exceptions import ControlFlowException
|
||||
from authentik.lib.sync.mapper import PropertyMappingManager
|
||||
from authentik.lib.sync.outgoing.exceptions import NotFoundSyncException, StopSync
|
||||
from authentik.lib.utils.errors import exception_to_string
|
||||
@ -92,7 +92,7 @@ class BaseOutgoingSyncClient[
|
||||
eval_kwargs.setdefault("user", None)
|
||||
for value in self.mapper.iter_eval(**eval_kwargs):
|
||||
always_merger.merge(raw_final_object, value)
|
||||
except SkipObjectException as exc:
|
||||
except ControlFlowException as exc:
|
||||
raise exc from exc
|
||||
except PropertyMappingExpressionException as exc:
|
||||
# Value error can be raised when assigning invalid data to an attribute
|
||||
|
||||
Reference in New Issue
Block a user