Repository navigation
Description
Description
OpenAEVConfigHelper.get_conf returns from inside its finally block (pyoaev/helpers.py#L249-L264):
def get_conf(self, variable, is_number=None, default=None, required=None):
result = None
try:
result = (
self.__config_obj.get(variable)
if (self.__config_obj.get(variable) is not None)
else default
)
except ConfigurationError:
result = default
finally:
if result is None and default is None and required:
raise ValueError(...)
return resultThe return in finally discards any exception that is not a ConfigurationError. For example, Configuration.get raises a ValueError when an is_number value is not a number. When that happens:
resultis never assigned, soget_confreturnsNone, even when adefaultis given;- with
required=True, it raisesCould not find required key ..., although the key is set: its value is just invalid.
The deprecated OpenAEVCollectorHelper and OpenAEVInjectorHelper read their whole configuration through get_conf (collector_log_level, openaev_url, injector_id, ...), and the nuclei and ai-redteam injectors call it directly. An invalid value is silently replaced by None instead of being reported.
Since Python 3.14 (PEP 765), compiling the module also emits SyntaxWarning: 'return' in a 'finally' block in every injector and collector that imports pyoaev.helpers.
The is_number parameter of get_conf is never used.
Environment
- OS: macOS (Darwin 27.2), arm64
- Version: pyoaev 3.261118.0 (same code on
mainat 36e8aeb) - Other environment details: same result on Python 3.12, 3.14 and 3.15; the
SyntaxWarningappears from Python 3.14
Reproducible steps
- Install
pyoaev==3.261118.0. - Run:
import os from pyoaev.configuration import Configuration from pyoaev.helpers import OpenAEVConfigHelper os.environ["COLLECTOR_PERIOD"] = "60s" # not a number config = Configuration( config_hints={"collector_period": {"env": "COLLECTOR_PERIOD", "is_number": True}} ) helper = OpenAEVConfigHelper.from_configuration_object(config) print(repr(helper.get_conf("collector_period"))) print(repr(helper.get_conf("collector_period", default=3600))) helper.get_conf("collector_period", required=True)
Expected output
The invalid value is reported, for example with the ValueError raised by the conversion (invalid literal for int() with base 10: '60s'). If the error is meant to be swallowed, get_conf(..., default=3600) returns 3600.
Actual output
None
None
ValueError: Could not find required key collector_period with no available default.
On Python 3.14 and later, importing pyoaev.helpers also prints:
pyoaev/helpers.py:264: SyntaxWarning: 'return' in a 'finally' block
Additional information
Proposed fix: move the required check and the return after the try/except block, so other exceptions propagate. Also, either use is_number or drop it.
Activity