Repository navigation
feat(alerts): alert definitions validate what changed, keep hand-written rules and watch several sources - #33969
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
| assertThrows( | ||
| Exception.class, | ||
| () -> createEntity(request), | ||
| "Multiple resources are not supported - only one resource can be specified"); | ||
| () -> createEntity(entityPlusActivity), | ||
| "Entity and activity sources share no filters and cannot be combined"); | ||
| assertThrows( | ||
| Exception.class, | ||
| () -> createEntity(wildcardPlusOne), | ||
| "The wildcard already watches everything and stands alone"); |
There was a problem hiding this comment.
💡 Quality: Rejection test passes on any failure, not the combining rule
Both assertThrows(Exception.class, ...) calls pass for any exception. The third argument is only the message JUnit shows when nothing is thrown; it is never compared to the server's error. SeveralSources checks several things in turn (not empty, every name known, the wildcard alone, one kind), so this test would also pass if conversation were rejected as an unknown name, or for an unrelated reason such as a destination or auth error. In that case the 'different kinds' and 'all stands alone' rules would not actually be tested. Catch the exception and check that its message contains the text SeveralSources uses, for example 'Sources of different kinds cannot be combined' and "The source 'all' already watches everything".
Check the server's rejection reason:
Exception mixed = assertThrows(Exception.class, () -> createEntity(entityPlusActivity));
assertTrue(mixed.getMessage().contains("Sources of different kinds cannot be combined"));
Exception wildcard = assertThrows(Exception.class, () -> createEntity(wildcardPlusOne));
assertTrue(wildcard.getMessage().contains("already watches everything"));
Was this helpful? React with 👍 / 👎
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…ten rules and watch several sources
…way the page provides them
…health stores only what ticks report
…channel is grouped from
…stopping flag and recipient lookups
…ed once and health per destination
…, fails the event with its reason
🚦 Removed from the merge queue —
|
Code Review 👍 Approved with suggestions 2 closed / 3 findings🟡 Medium risk · Alert validation and multi-source matching change backend alert evaluation and delivery Adds validation of alert definitions only when they change, preserves hand-written rules and triggers, and enables watching multiple sources of one kind through a new capabilities endpoint. The test for combining-rule rejection passes on any exception rather than checking the specific error message, so it should verify that the server's message contains the expected text like 'Sources of different kinds cannot be combined' or 'The source 'all' already watches everything'. 💡 Quality: Rejection test passes on any failure, not the combining ruleBoth Check the server's rejection reason✅ 2 closed✅ Security: Capabilities warning reveals which service names exist, ignoring authz
✅ Edge Case: Hand-written triggers (filteringRules.actions) are not treated as hand-written
🤖 Prompt for agentsOptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
| Count | Rule |
|---|---|
| 14 | react-hooks/exhaustive-deps |
| 13 | openmetadata-imports/no-lower-layer-page-imports |
| 1 | openmetadata-imports/no-cross-page-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/Alerts/AlertDetails/AlertConfigDetails/AlertConfigDetails.tsx:34:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Alerts/AlertDetails/AlertConfigDetails/AlertConfigDetails.tsx:108:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/components/Alerts/AlertDetails/AlertConfigDetails/AlertConfigDetails.tsx:139:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'getResourcePermission' and 't'. Either include them or remove the dependency array. |
| 🟡 | src/components/Alerts/AlertDetails/AlertConfigDetails/AlertConfigDetails.tsx:145:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchTemplates'. Either include it or remove the dependency array. |
| 🟡 | src/components/Alerts/AlertDetails/AlertConfigDetails/AlertConfigDetails.tsx:149:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchFunctions'. Either include it or remove the dependency array. Outer scope values like 'Fqn' aren't valid de |
| 🟡 | src/components/Alerts/AlertFormSourceItem/AlertFormSourceItem.tsx:114:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'form'. Either include it or remove the dependency array. |
| 🟡 | src/components/Alerts/DestinationFormItem/DestinationFormItem.component.tsx:36:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Alerts/DestinationFormItem/DestinationFormItem.component.tsx:72:9 |
react-hooks/exhaustive-deps |
The 'destinations' logical expression could make the dependencies of useMemo Hook (at line 86) change on every render. To fix this, wrap the initialization of ' |
| 🟡 | src/components/Alerts/DestinationFormItem/DestinationFormItem.component.tsx:72:9 |
react-hooks/exhaustive-deps |
The 'destinations' logical expression could make the dependencies of useCallback Hook (at line 146) change on every render. To fix this, wrap the initialization |
| 🟡 | src/components/Alerts/DestinationFormItem/DestinationFormItemFormBridge.tsx:19:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Alerts/DestinationFormItem/DestinationSelectItem/DestinationSelectItem.tsx:60:9 |
react-hooks/exhaustive-deps |
The 'destinationItem' logical expression could make the dependencies of useMemo Hook (at line 105) change on every render. To fix this, wrap the initialization |
| 🟡 | src/components/observability/Alerts/AlertAiDestinationSection.component.tsx:60:9 |
react-hooks/exhaustive-deps |
The 'destinations' logical expression could make the dependencies of useCallback Hook (at line 107) change on every render. To fix this, wrap the initialization |
| 🟡 | src/components/observability/Alerts/AlertAiFormFields.component.test.tsx:47:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertAiFormFields.interface.ts:24:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertAiFormFieldsSearchUtils.ts:20:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertDetailsPage.test.tsx:29:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertDetailsPage.tsx:46:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertEditModal.component.test.tsx:30:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertEditModal.component.tsx:25:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/observability/Alerts/AlertEditModal.component.tsx:29:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:85:1 |
openmetadata-imports/no-cross-page-imports |
Page features must not import another page feature. Move shared code to components, hooks, interfaces, or pure utilities. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:148:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:193:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'fetchAlert' and 'fetchFunctions'. Either include them or remove the dependency array. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:221:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'getResourceLimit' and 'setInlineAlertDetails'. Either include them or remove the dependency array. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:282:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'getResourcePermission' and 't'. Either include them or remove the dependency array. |
| 🟡 | src/pages/AddNotificationPage/AddNotificationPage.tsx:288:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchTemplates'. Either include it or remove the dependency array. |
| 🟡 | src/utils/Alerts/AlertsUtil.test.tsx:36:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/utils/Alerts/AlertsUtilPure.ts:42:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed
|
|



Fixes #20504
What this pull request implements
POST /v1/events/subscriptions/capabilities, tells a client which filters and triggers a selection of sources supports, and why a source cannot join it.What was wrong before
Every save rebuilt the alert's rules from the form's selections and checked the whole definition. An alert stored under older rules failed every later save, even a rename, and conditions written by hand were replaced. The save also accepted only one source. The 2.0 upgrade makes mention alerts watch conversations and tasks, so they could no longer be edited.
Design
AlertDefinitionholds what an alert watches and when it fires, as the user chose it, plus the stored rules compiled from those choices. It compares the incoming definition with the stored one and validates only what changed.AlertDefinitionPolicyrecords where an alert's rules come from. Rules compiled from form selections are compiled again on every save. Rules or triggers written by hand, by the system or by another product have no selections behind them, so only rules a save carries replace them; a request has no place for rules, so the mapper leaves them absent. An alert keeps its kind until a save brings selections.SeveralSourcesholds the rules for combining sources: the sources are "any of", the filters "all of", and a trigger applies only to the sources that support it. Anything else is refused with a message that names the rule.StoredRuleschecks the stored rules, whoever wrote them.SourceCapabilitiesworks out what a selection supports with the same code the save uses, so a client cannot offer what the save would reject; the new endpoint serves it.UnreachableSourceexplains, from the catalog alone, a selected source that can never match with what has been chosen so far; it never looks a chosen name up. Such an alert still saves, and the client can show the reason as a warning.What users notice
How it was tested
The alerting unit tests (54 classes, 457 tests), the new
AlertDefinitionITandCapabilitiesIT(21 tests) and the existing alert integration tests (565 tests) pass on MySQL and on PostgreSQL.