diff --git a/logprep/filter/expression/filter_expression.py b/logprep/filter/expression/filter_expression.py index 3936250ec..31153ab99 100644 --- a/logprep/filter/expression/filter_expression.py +++ b/logprep/filter/expression/filter_expression.py @@ -85,12 +85,11 @@ def _get_value(key: List[str], document: dict) -> Any: current = document for item in key: + if not isinstance(current, dict): + raise KeyDoesNotExistError if item not in current: raise KeyDoesNotExistError - try: - current = current[item] - except TypeError as error: - raise KeyDoesNotExistError from error + current = current[item] return current def __eq__(self, other):