Bug: condition/stop and other unknown params silently forwarded to wait_gen_kwargs in decorators
Severity: Medium
File: _decorator.py:370 (on_exception) and _decorator.py:62 (on_predicate)
Version: 4.2.4 (commit 0992494)
Description
The @on_exception and @on_predicate decorators accept **wait_gen_kwargs and pass them to _init_wait_gen, which forwards them to the wait generator. However, advanced parameters like condition, stop, and name that exist in Retrying and retry() are NOT in the decorator signatures. If a user passes them to a decorator, they go to **wait_gen_kwargs and then to the wait generator, causing a confusing TypeError:
TypeError: _Expo.__init__() got an unexpected keyword argument 'condition'
To Reproduce
import backon
from backon import retry_if_exception_message
cond = retry_if_exception_message("fail")
@backon.on_exception(backon.expo, ValueError, max_tries=3, condition=cond, jitter=None)
def fail():
raise ValueError("fail")
Output:
TypeError: _Expo.__init__() got an unexpected keyword argument 'condition'
The error mentions _Expo instead of saying "condition is not a valid parameter for on_exception", which is misleading.
Suggested Fix
Either:
- Add
condition and stop as explicit None parameters to the decorators (even if ignored) so they are consumed rather than forwarded
- Or add validation in
_init_wait_gen to detect unexpected kwargs and provide a clear error message
Bug:
condition/stopand other unknown params silently forwarded towait_gen_kwargsin decoratorsSeverity: Medium
File:
_decorator.py:370(on_exception) and_decorator.py:62(on_predicate)Version: 4.2.4 (commit 0992494)
Description
The
@on_exceptionand@on_predicatedecorators accept**wait_gen_kwargsand pass them to_init_wait_gen, which forwards them to the wait generator. However, advanced parameters likecondition,stop, andnamethat exist inRetryingandretry()are NOT in the decorator signatures. If a user passes them to a decorator, they go to**wait_gen_kwargsand then to the wait generator, causing a confusingTypeError:To Reproduce
Output:
The error mentions
_Expoinstead of saying "condition is not a valid parameter for on_exception", which is misleading.Suggested Fix
Either:
conditionandstopas explicitNoneparameters to the decorators (even if ignored) so they are consumed rather than forwarded_init_wait_gento detect unexpected kwargs and provide a clear error message