From 1335b7e77bde1a14af009d386fbcfc64bb523e6d Mon Sep 17 00:00:00 2001 From: big1hc Date: Wed, 9 Aug 2023 19:02:20 +0700 Subject: [PATCH] bugfix in filter_needs --- sphinx_needs/filter_common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sphinx_needs/filter_common.py b/sphinx_needs/filter_common.py index 250bc40aa..f39f478f7 100644 --- a/sphinx_needs/filter_common.py +++ b/sphinx_needs/filter_common.py @@ -309,6 +309,11 @@ def filter_single_need( result = bool(eval(filter_compiled, filter_context)) else: result = bool(eval(filter_string, filter_context)) + if result not in (True, False): + # Raises NeedsInvalidFilter if the result is not equal True/False + raise NeedsInvalidFilter( + f"Error when evaluating filter: expected output to have True/False but got a result <{result}>" + ) except Exception as e: raise NeedsInvalidFilter(f"Filter {filter_string} not valid. Error: {e}.") return result