Repository navigation
fix(frontend): handle model hits in search-bar autocomplete - #8701
Conversation
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
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Removing release/v1.2: the root cause (#7930, model search) is not on that branch. |
|
Removing release/v1.3 too: the root cause (#7930, model search) isn't on that branch either, so the backport fails to compile on |
bobbai00
left a comment
There was a problem hiding this comment.
🟡 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 aconvertToNamekind 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.
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, andSearchService.searchkeeps them.SearchBarComponent.convertToNamehad no model branch, so a model row threwUnexpected type in SearchResult.inside theswitchMapfeeding 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.Two changes:
searchResultPayload(item)insearch-result.tsreturns a row's workflow, dataset or model payload, orundefined. TheSearchService.searchfilter, its hub enrichment andconvertToNameall read through it, so every row the filter keeps is one the search bar can name, model rows included. Before, the filter andconvertToNameeach listed the kinds, and feat(frontend, amber): add models to the hub and unified search #7930 updated only the filter.getSearchResultsnow catches errors from the request alone, asFiltersComponentdoes. A failed search clears the suggestions and caches nothing, so typing the same text again retries. A rowconvertToNamecannot 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.tsdid not compile withoutsearchResultPayload. All pass with the fix:searchResultPayloadon a workflow, dataset or model rowsearchResultPayloadon an unmodelled kind, or anullpayload fieldundefinedsearchresponse with an unmodelled row and a row whose payload fields are allnullconvertToNameon a model-only rowconvertToNamecannot nameMutation check, each run against the three specs below and each caught:
defaultIfEmpty, fails the failed-request case;?? undefinedfrom the helper fails thenull-payload case;convertToNameor enrichment lookup that no longer covers models fails the model cases;resourceTypecheck) 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 withsrc/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