Skip to content

fix(frontend): handle model hits in search-bar autocomplete - #8701

Merged
aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:fix/search-bar-model-hits
Oct 26, 2026
Merged

aglinxinyuan merged 4 commits into
apache:mainfrom
aglinxinyuan:fix/search-bar-model-hits

Conversation

@aglinxinyuan

@aglinxinyuan aglinxinyuan commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Root cause. The dashboard search bar searches every resource kind (type = null). Since #7930 that query returns model rows too, and SearchService.search keeps them. SearchBarComponent.convertToName had no model branch, so a model row threw Unexpected type in SearchResult. inside the switchMap feeding the component's only search subscription. That subscription has no error handler, so the throw ended it and every later keystroke was dropped until reload.

Before:  type "my" -> a model matches -> convertToName throws -> subscription closed
         type "wf" -> no request, no suggestions (rest of the session)
After:   type "my" -> "my-model" suggested
         a failed request -> no suggestions for that query, nothing cached -> type "wf" -> searches as normal

Two changes:

  1. One payload lookup. searchResultPayload(item) in search-result.ts returns a row's workflow, dataset or model payload, or undefined. The SearchService.search filter, its hub enrichment and convertToName all read through it, so every row the filter keeps is one the search bar can name, model rows included. Before, the filter and convertToName each listed the kinds, and feat(frontend, amber): add models to the hub and unified search #7930 updated only the filter.
  2. Only the request is guarded. Both HTTP interceptors rethrow, so a 5xx, a dropped connection or a 401 also ended the subscription. getSearchResults now catches errors from the request alone, as FiltersComponent does. A failed search clears the suggestions and caches nothing, so typing the same text again retries. A row convertToName cannot name is a bug, so it is not caught and still reaches the console.

Any related issues, documentation, discussions?

Closes #8700.

How was this PR tested?

Tests came first: on unchanged source the new search-bar cases failed, and search-result.spec.ts did not compile without searchResultPayload. All pass with the fix:

Case Pins
searchResultPayload on a workflow, dataset or model row returns that row's payload
searchResultPayload on an unmodelled kind, or a null payload field undefined
search response with an unmodelled row and a row whose payload fields are all null both dropped, the workflow row kept
convertToName on a model-only row returns the model's name
model-only search response the model's name is listed
response with a row convertToName cannot name the error reaches RxJS's unhandled-error hook instead of an empty dropdown
failed request (HTTP 500) that query lists nothing and is not cached; retrying the same query hits the server and lists results

Mutation check, each run against the three specs below and each caught:

  • moving the catch back below the naming step fails the unnameable-row case;
  • dropping the request catch, or defaultIfEmpty, fails the failed-request case;
  • dropping ?? undefined from the helper fails the null-payload case;
  • a filter, convertToName or enrichment lookup that no longer covers models fails the model cases;
  • a filter that stops using the helper (an inline lookup, or a resourceType check) fails the funnel case.

From frontend/:

  • npx ng test --watch=false --include='**/search-bar.component.spec.ts' --include='**/dashboard/type/search-result.spec.ts' --include='**/dashboard/service/user/search.service.spec.ts': 36 passed.
  • yarn --cwd frontend format:ci (from the repo root): clean.
  • node node_modules/typescript/bin/tsc -p src/tsconfig.spec.json --noEmit, and the same with src/tsconfig.app.json: no errors.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with Claude Code

convertToName had no model branch, so a model row from the all-kinds
search threw inside the search bar's switchMap and ended its only
subscription, leaving autocomplete dead for the session. Name model
rows, and catch errors per query so a failed request or an unnameable
row costs that query's suggestions instead of the subscription.

Closes apache#8700
Copilot AI lite review requested due to automatic review settings September 27, 2026 00:35

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 fix frontend Changes related to the frontend GUI labels Sep 27, 2026
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Sep 27, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 September 27, 2026 00:35
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @tanishqgandhi1908
    You can notify them by mentioning @tanishqgandhi1908 in a comment.

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
🚫 release/v1.3 Label was removed earlier (opt-out); not re-added. Re-add it by hand if this fix should be backported here after all — the branch's release manager then has to approve before this PR can merge.
🚫 release/v1.2 Label was removed earlier (opt-out); not re-added. Re-add it by hand if this fix should be backported here after all — the branch's release manager then has to approve before this PR can merge.

Auto-label run.

@codecov-commenter

codecov-commenter commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.33%. Comparing base (22b82a2) to head (0cd2377).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8701      +/-   ##
============================================
- Coverage     92.33%   92.33%   -0.01%     
  Complexity     5045     5045              
============================================
  Files          1261     1267       +6     
  Lines         54120    54538     +418     
  Branches       6768     6885     +117     
============================================
+ Hits          49974    50359     +385     
- Misses         2486     2498      +12     
- Partials       1660     1681      +21     
Flag Coverage Δ *Carryforward flag
access-control-service 77.38% <ø> (ø) Carriedforward from 242daeb
agent-service 99.16% <ø> (ø) Carriedforward from 242daeb
amber 87.31% <ø> (ø) Carriedforward from 242daeb
computing-unit-managing-service 60.48% <ø> (ø) Carriedforward from 242daeb
config-service 87.37% <ø> (ø) Carriedforward from 242daeb
file-service 82.00% <ø> (ø) Carriedforward from 242daeb
frontend 96.49% <100.00%> (-0.07%) ⬇️
notebook-migration-service 83.73% <ø> (ø) Carriedforward from 242daeb
pyamber 98.51% <ø> (-0.07%) ⬇️ Carriedforward from 242daeb
workflow-compiling-service 72.43% <ø> (ø) Carriedforward from 242daeb

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aglinxinyuan aglinxinyuan reopened this Sep 27, 2026
@xuang7 xuang7 removed the release/v1.2 back porting to release/v1.2 label Sep 28, 2026
@xuang7

xuang7 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Removing release/v1.2: the root cause (#7930, model search) is not on that branch.

@aglinxinyuan aglinxinyuan removed the release/v1.3 back porting to release/v1.3 label Oct 21, 2026
@aglinxinyuan

Copy link
Copy Markdown
Contributor Author

Removing release/v1.3 too: the root cause (#7930, model search) isn't on that branch either, so the backport fails to compile on SearchResultItem.model.

@aglinxinyuan
aglinxinyuan requested a review from bobbai00 October 21, 2026 04:06

@bobbai00 bobbai00 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.

🟡 0 must-fix · 1 advisory · 0 polish: a correct, well-tested fix for #8700, with one note on keeping the next kind drift visible.

Design & architecture (1)

  • search-bar.component.ts:118: the catch also silences a convertToName kind drift (advisory, see inline)
Verification trace

Traced the per-query pipeline at the head. An HTTP error and a convertToName throw both reach the catch before addToCache runs, so a failed query is never cached and typing it again retries. The 401 interceptor logs out and notifies before it rethrows, so the catch does not hide session expiry. Nothing in SearchService.search can throw before the observable exists, so the constructor's subscription only ever sees successful emissions.

searchResultPayload is the lookup the search filter, the hub enrichment
and convertToName should share. The funnel spec gains a row whose
payload fields are null, as the server writes an absent payload, and a
row the search bar cannot name must reach the console instead of an
empty dropdown.
The SearchService filter, its hub enrichment and convertToName now
read a row's payload through searchResultPayload, so the rows the
filter keeps are exactly the rows the search bar can name. The search
bar's catch wraps only the request, as FiltersComponent does: a failed
search still clears the suggestions and caches nothing, while a naming
error is no longer swallowed into a silent empty dropdown.

@bobbai00 bobbai00 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.

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Oct 26, 2026
Merged via the queue into apache:main with commit 4bad5e4 Oct 26, 2026
30 checks passed
@aglinxinyuan
aglinxinyuan deleted the fix/search-bar-model-hits branch October 26, 2026 23:22
mengw15 added a commit that referenced this pull request Oct 30, 2026
…the #9090 test)

#9090 added its test right before three tests from #8701, which is not on
release/v1.3, so the cherry-pick conflicted. Keep only the #9090 test; the
#8701 tests use helpers this branch does not have.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search bar autocomplete stops working after a model appears in the suggestions

6 participants