Skip to content

Keep a typed alert argument search when the source search is rebuilt - #35683

Open
chirag-madlani wants to merge 2 commits into
mainfrom
alert-search-debounce-race
Open

chirag-madlani wants to merge 2 commits into
mainfrom
alert-search-debounce-race

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes a race in the alert form's searchable rule arguments (e.g. the Updater Name user picker): a search typed right after adding a filter could be silently dropped. The text stays in the input, but no search request is ever sent, so the list keeps showing the unfiltered defaults.

Cause. In AiArgumentAutocomplete (AlertAiRuleSection.component.tsx), debouncedSearch (500 ms) was memoized on [argument, selectedSource, sourceSearch, stableContainerEntities], and an effect cancels it on cleanup. Adding a filter changes the form input → useAlertCapabilities re-asks the server → when it answers, useAlertSelection hands out a new search object → debouncedSearch is rebuilt and the pending typed search is .cancel()led.

Fix. Read those params through a ref (the component already does this for selectedValues), so the debounced function is created once and only cancelled on unmount.

This is what blocked the merge queue for #35678 on Flow/NotificationAlerts.spec.ts › Multiple Filters Alert (run 39030428697). The retry trace shows only two index=user&q= (empty query) requests about 950 ms apart, the second being the dependency change re-running the initial load, and never the typed name. The first attempt timed out on the same form with the filter option detaching.

Testing

  • Unit (RED → GREEN): new test in AlertAiFormFields.component.test.tsx, keeps a typed search when the source search is rebuilt during the debounce. It types, rerenders with a new sourceSearch, and advances the debounce. Before the fix it fails with the only searchQuery call being query: "", the same thing CI showed. Both alert suites now pass 50/50 (AlertAiFormFields.component.test.tsx, ClassicAlertRuleSection.test.tsx).
  • Playwright, local: production build of this branch served in front of a local backend, PLAYWRIGHT_RETRIES=0:
    • Flow/NotificationAlerts.spec.ts + Flow/ObservabilityAlerts.spec.ts: all 17 tests pass (the 4 webhook tests with PLAYWRIGHT_WEBHOOK_HOST=host.docker.internal).
    • Multiple Filters Alert with --repeat-each=3: 3/3 pass.

Type of change:

  • Bug fix

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

Keeps a pending alert argument search when search settings change.

  • Alert argument searches keep running when filter details refresh.
  • The profiler ingestion form spec joins two Playwright impact groups.

Reviews (1) · Last reviewed commit: "chore(playwright): auto-refresh impact-m..." · Reviewed by Greptile

Adding a filter re-asks the server what the selection supports, which hands
the argument autocomplete a new sourceSearch. debouncedSearch depended on it,
so it was rebuilt and the cleanup cancelled the search the user was still
typing: the text stayed in the input but no search request was ever sent.
Read the search params through a ref so the debounced function is created
once and only cancelled on unmount.

This is the cause of the intermittent NotificationAlerts > Multiple Filters
Alert timeouts in the merge queue.
Copilot AI balanced review requested due to automatic review settings October 17, 2026 13:46
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 944 → 944
- 0 added, 0 removed, 2 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/utils/apiResponse.ts
  openmetadata-ui/src/main/resources/ui/src/components/Settings/Services/AddIngestion/AddIngestion.component.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

Copilot AI balanced review requested due to automatic review settings October 17, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Preserving pending alert-argument searches across source rebuilds changes option lookup timing, which could display an incorrect set of rule choices.

Fixes a race in the alert form's searchable rule arguments where a search typed right after adding a filter was silently dropped. The debounced search now reads its parameters through a ref, so it is only cancelled on unmount rather than on every rebuild. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

❌ UI Checkstyle Failed

❌ ESLint + Prettier + Organise Imports (src)

One or more source files have linting or formatting issues.

Affected files
  • openmetadata-ui/src/main/resources/ui/src/components/observability/Alerts/AlertAiFormFields.component.test.tsx

🔍 ESLint findings in this PR's files — 0 error(s), 2 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 2 warning(s) across 2 changed file(s).

Count Rule
1 openmetadata-imports/no-lower-layer-page-imports
1 react-hooks/exhaustive-deps
All findings
Location Rule Message
🟡 src/components/observability/Alerts/AlertAiFormFields.component.test.tsx:49: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/AlertAiRuleSection.component.tsx:537:9 react-hooks/exhaustive-deps The 'selectedRules' logical expression could make the dependencies of useMemo Hook (at line 542) change on every render. To fix this, wrap the initialization of

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 78%
78.59% (129940/165321) 65.36% (82635/126430) 66.7% (27612/41392)

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants