Skip to content

Conversation

@bentsku
Copy link
Contributor

@bentsku bentsku commented Oct 14, 2025

Motivation

We got a report from a user that when using anything-but with nested suffix, and the target field was missing from the event, we would raise an internal error as we were not handling null value accordingly.

We need to differentiate between 2 kind of null value: missing value (result of event.get()) and user-set null.

If the user is setting the value to null, the default behavior of anything-but works, meaning that it returns true like any string not matching the pattern would.
If the value is missing entirely, then we're not in the "anything but" case, and it returns False.

Changes

  • add validation for null value in the pattern for anything-but patterns
  • add lots of test cases around anything-but and its nested conditions with both missing values and user-set null values
  • fix the behavior to properly take into account null values, and handle them depending on their existence or not

@bentsku bentsku added this to the 4.10 milestone Oct 14, 2025
@bentsku bentsku self-assigned this Oct 14, 2025
@bentsku bentsku added aws:events Amazon EventBridge semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Oct 14, 2025
@github-actions
Copy link

github-actions bot commented Oct 14, 2025

Test Results - Preflight, Unit

22 337 tests  ±0   20 587 ✅ ±0   15m 53s ⏱️ +22s
     1 suites ±0    1 750 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit d7e2d4b. ± Comparison against base commit 73e4f6c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 23s ⏱️ +2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit d7e2d4b. ± Comparison against base commit 73e4f6c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

Test Results - Alternative Providers

406 tests   274 ✅  4m 8s ⏱️
  1 suites  132 💤
  1 files      0 ❌

Results for commit d7e2d4b.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   58m 15s ⏱️ - 1h 1m 11s
2 680 tests  - 2 136  2 572 ✅  - 1 907  108 💤  - 229  0 ❌ ±0 
2 682 runs   - 2 136  2 572 ✅  - 1 907  110 💤  - 229  0 ❌ ±0 

Results for commit d7e2d4b. ± Comparison against base commit 73e4f6c.

This pull request removes 2163 and adds 27 tests. Note that renamed tests count towards both.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_ignorecase_list_missing_NEG]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_ignorecase_list_null]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_ignorecase_missing_NEG]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_ignorecase_null]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_string_list_missing_NEG]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_string_list_null]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_string_list_null_type_EXC]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_string_missing_NEG]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_but_string_null_type_EXC]
tests.aws.services.events.test_events_patterns.TestEventPattern ‑ test_event_pattern[content_anything_prefix_int_value]
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   1h 24m 14s ⏱️
2 704 tests 2 599 ✅ 105 💤 0 ❌
2 710 runs  2 599 ✅ 111 💤 0 ❌

Results for commit d7e2d4b.

♻️ This comment has been updated with latest results.

@bentsku bentsku marked this pull request as ready for review October 14, 2025 18:08
@bentsku bentsku requested a review from maxhoheiser as a code owner October 14, 2025 18:08
Copy link
Member

@maxhoheiser maxhoheiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greate changes, I noticed a few small gaps and nits, but after these are addressed good to merge.
Good catch that we need the null checks in the _evaluate... methods.

Quite a lot of tests to cover this 👍

Nit:
if (suffix_equal_ignore_case := suffix.get("equals-ignore-case")) is not None: should we use the walrus operator more frequently?

# anything-but can actually contain any kind of simple rule (str, number, and list) except Null
if value is None:
raise InvalidEventPatternException(
f"{self.error_prefix}Value of anything-but must be an array or single string/number value."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"{self.error_prefix}Value of anything-but must be an array or single string/number value."
f"{self.error_prefix}"Value of anything-but cannot be null. Expected array or string/number value."

nit - this might be clearer that null is absolutely not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a parity error returned by AWS, and while I agree with the comment, can't do anything about it 😄

self._validate_rule(v)
if v is None:
raise InvalidEventPatternException(
f"{self.error_prefix}Inside anything but list, start|null|boolean is not supported."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be string? or what is start :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above, AWS returns this error, I also don't know what start means 🤷‍♂️

Copy link
Contributor Author

@bentsku bentsku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the review! Also added the missing type hints in the _evaluate_* methods that you spotted, good catch! I've changed them to t.Any to take into the account they could be also something else than None and properly handle those cases to be strictly strings, we're now properly covered I believe.

Edit: regarding the walrus operator, I tend to use it quite frequently, it especially helps here 👍

# anything-but can actually contain any kind of simple rule (str, number, and list) except Null
if value is None:
raise InvalidEventPatternException(
f"{self.error_prefix}Value of anything-but must be an array or single string/number value."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a parity error returned by AWS, and while I agree with the comment, can't do anything about it 😄

self._validate_rule(v)
if v is None:
raise InvalidEventPatternException(
f"{self.error_prefix}Inside anything but list, start|null|boolean is not supported."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above, AWS returns this error, I also don't know what start means 🤷‍♂️

@bentsku bentsku merged commit 76c6c86 into main Oct 15, 2025
40 checks passed
@bentsku bentsku deleted the fix-eventbridge-rule branch October 15, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:events Amazon EventBridge docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants