Skip to content

Feature request: surface comparator exceptions as misconfiguration instead of silent non-match #8425

Description

@dreamorosi

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:

  1. 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.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requesttriagePending triage from maintainers

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions