Use case
_match_by_action catches every Exception from a comparator, logs it at debug, and returns False. A type mismatch between a context value and a condition value (STARTSWITH on an int, KEY_GREATER_THAN_VALUE between str and int, a non-list context for ANY_IN_VALUE) therefore looks identical to "condition evaluated and did not match". In production, with debug logging off, a misconfigured rule is indistinguishable from a rule that correctly excludes the user, and it can stay that way for months.
Solution/User Experience
Two steps:
- Now (minor, no behaviour change): log the swallowed exception at
warning rather than debug, including feature name, rule name, key, and action, so the problem is visible in default log output.
- Next major: raise a dedicated error (e.g.
ConditionEvaluationError, in the SchemaValidationError family) naming feature, rule, key and action. Keep validation_exception_handler as the opt-in to restore "return a boolean instead of raising" for anyone who wants the old behaviour.
Context: the TypeScript port (aws-powertools/powertools-lambda-typescript#5614) throws on incompatible operands from day one; this proposal brings Python to the same place across a major.
Alternative solutions
Keep swallowing but add an `on_comparator_error` callback. Functionally the same as the existing handler; doesn't address the default being silent.
Acknowledgment
Use case
_match_by_actioncatches everyExceptionfrom a comparator, logs it atdebug, and returnsFalse. A type mismatch between a context value and a condition value (STARTSWITHon anint,KEY_GREATER_THAN_VALUEbetweenstrandint, a non-list context forANY_IN_VALUE) therefore looks identical to "condition evaluated and did not match". In production, with debug logging off, a misconfigured rule is indistinguishable from a rule that correctly excludes the user, and it can stay that way for months.Solution/User Experience
Two steps:
warningrather thandebug, including feature name, rule name, key, and action, so the problem is visible in default log output.ConditionEvaluationError, in theSchemaValidationErrorfamily) naming feature, rule, key and action. Keepvalidation_exception_handleras the opt-in to restore "return a boolean instead of raising" for anyone who wants the old behaviour.Context: the TypeScript port (aws-powertools/powertools-lambda-typescript#5614) throws on incompatible operands from day one; this proposal brings Python to the same place across a major.
Alternative solutions
Acknowledgment