From f6e7c6ff4d69229373e49e51168c5f0acaba4d45 Mon Sep 17 00:00:00 2001 From: Piotr Pauksztelo Date: Thu, 5 Dec 2024 13:44:21 +0100 Subject: [PATCH] Refactor fix of FilterExpression to prevent incorrect matching --- logprep/filter/expression/filter_expression.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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):