Skip to content

fix(search): key search results by urn so a re-sort does not crash the page - #21909

Open
v-tarasevich-blitz-brain wants to merge 1 commit into
masterfrom
vt--cat-4285--unstable-search-page
Open

v-tarasevich-blitz-brain wants to merge 1 commit into
masterfrom
vt--cat-4285--unstable-search-page

Conversation

@v-tarasevich-blitz-brain

@v-tarasevich-blitz-brain v-tarasevich-blitz-brain commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The search results list (app/searchV2/SearchResultList.tsx) renders an antd List without a rowKey. In that case antd keys each row by its position (list-item-${index}).

After a re-sort or a new query, the same React component instance at a given position renders whichever entity now lands there, instead of a fresh card being mounted for the new entity. Any per-card state, and any hooks that depend on the entity, carry over from the previous entity.

In OSS this is latent today. It becomes a crash as soon as a card's hooks depend on the entity type: for example, a card menu that calls a delete-mutation hook only for some entity types changes its hook count when the entity at that position changes type, and React throws "Rendered more hooks than during the previous render", which replaces the results with the error boundary. DataHub Cloud hit exactly this with its configurable search card after switching the sort a few times.

Fix

  • Pass rowKey={(item) => item.entity.urn} to the List in SearchResultList. Each entity gets its own card, so one card instance never renders two different entities. Search results are unique by urn.
  • A card is now remounted when a different entity takes its position, instead of being re-rendered with new props.

The same change is in DataHub Cloud, so this keeps OSS and DataHub Cloud aligned.

Verification

  • yarn type-check passes.

  • eslint and prettier --check pass on the changed file.

  • The PR conforms to DataHub's Contributing Guideline (PR Title Format)

🤖 Generated with Claude Code


Summary by cubic

Fixes a crash on the unstable search page that happened after re-sorting results. The antd List in SearchResultList now keys each row by the entity URN instead of its list position, so when a re-sort moves a different entity into a given position, its card is remounted rather than reused with new props. This prevents React from throwing "Rendered more hooks than during the previous render" when card hooks depend on the entity type.

Written for commit e6f6509. Summary will update on new commits.

View guided diff Turn on auto-fix

@github-actions github-actions Bot added the product PR or Issue related to the DataHub UI/UX label Dec 4, 2026
@cursor

cursor Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds rowKey={(item) => item.entity.urn} on the search v2 ResultList (antd List) so each row is keyed by entity instead of list index.

After a re-sort or new query, React now remounts cards when a different entity occupies a slot, instead of reusing the same card instance with new props. That prevents stale per-card state and avoids hook-order crashes (e.g. entity-type-specific menus changing hook count at the same index), which DataHub Cloud saw when sorting search results.

Reviewed by Cursor Bugbot for commit e6f6509. Bugbot is set up for automated code reviews on this repo. Configure here.

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="datahub-web-react/src/app/searchV2/SearchResultList.tsx">

<violation number="1" location="datahub-web-react/src/app/searchV2/SearchResultList.tsx:250">
P2: Custom agent: **Enforce Pragmatic Test Coverage**

This fixes a user-visible crash during re-sorting, but no test exercises changing result order and verifies cards remount without a hook-count error. Add a regression test for that transition.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

id="search-result-list"
$isShowNavBarRedesign={isShowNavBarRedesign}
dataSource={searchResults}
rowKey={(item) => item.entity.urn}

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.

P2: Custom agent: Enforce Pragmatic Test Coverage

This fixes a user-visible crash during re-sorting, but no test exercises changing result order and verifies cards remount without a hook-count error. Add a regression test for that transition.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At datahub-web-react/src/app/searchV2/SearchResultList.tsx, line 250:

<comment>This fixes a user-visible crash during re-sorting, but no test exercises changing result order and verifies cards remount without a hook-count error. Add a regression test for that transition.</comment>

<file context>
@@ -247,6 +247,7 @@ export const SearchResultList = ({
             id="search-result-list"
             $isShowNavBarRedesign={isShowNavBarRedesign}
             dataSource={searchResults}
+            rowKey={(item) => item.entity.urn}
             split={false}
             locale={{ emptyText: (!loading && <EmptySearchResults suggestions={suggestions} />) || <></> }}
</file context>

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Smart test selection

Playwright E2E tests

This run: smart

  • Selection: smart: specs tagged search plus the tests the change affects
  • Size: 52 tests in 8 spec files, ~9 min predicted on 2 shard(s)
Specs selected because of this PR (8)
Spec Tests Why
autocomplete-v2/autocomplete.spec.ts 2/2 tagged search
browse-v2/browse-v2.spec.ts 10/10 tagged search
logical-models/physical-children-view.spec.ts 2/2 tagged search
search/query-and-filter-search.spec.ts 10/10 tagged search
search/search-filters.spec.ts 5/5 tagged search
search/search-within-operator.spec.ts 1/1 tagged search
search/search.spec.ts 7/7 tagged search
search/searchv2.spec.ts 15/15 tagged search

Add the run-all-tests:playwright label to run the full Playwright suite on this PR.

commit e6f6509 · workflow run

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

i18n locale parity

Status: ⚠️ drift detected (warn-only) — 135 issue(s) across 13 locale(s)

Locale Missing keys Stale keys Placeholder Files
de 153 10 0 10
es 153 10 0 10
fi 153 12 0 11
fr 153 10 0 10
hu 153 10 0 10
it 153 10 0 10
ja 153 12 0 11
nb 153 10 0 10
pt-BR 153 10 0 10
ru 153 13 0 12
sv 153 10 0 10
zh-CN 153 10 0 10
zh-TW 153 12 0 11

Per-key detail is in the job summary of the datahub-web-react-lint run, or reproduce locally:

./gradlew :datahub-web-react:yarnI18nParityCheck        # all locales
cd datahub-web-react && yarn check-i18n-parity --lang de  # one locale

@codecov

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 23 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
datahub-react-web-esm 31.56MB 23 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: datahub-react-web-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/AuthenticatedApp-*.js 23 bytes 1.89MB 0.0%

Files in assets/AuthenticatedApp-*.js:

  • ./src/app/searchV2/SearchResultList.tsx → Total Size: 7.66kB

@meticulous

meticulous Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Meticulous spotted 0 visual differences across 320 screens tested: view results.

Meticulous evaluated ~18 hours of user flows which tested 100% of the executable lines edited in your PR.

Expected differences? Click here. Last updated for commit e6f6509 fix(search): key search results by urn so a re-sort does not crash the p.... This comment will update as new commits are pushed.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Initial JS bundle size ➡️

Base (02f8a84) This PR Diff
index.html (/login) 250 KB 250 KB +0 KB (+0.0%)
Logged-in shell 1.07 MB 1.07 MB +0 KB (+0.0%)
/search 1.25 MB 1.25 MB -0 KB (-0.0%)
/ (home) 1.27 MB 1.27 MB -0 KB (-0.0%)

index.html is the login page; logged-in pages add the shell. Gzip of the JS loaded before first paint. Codecov reports total bundle including lazy chunks — these intentionally differ.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Boot web vitals (no backend)

Unauthenticated /login against the two dist/ trees from this job. No GMS — this is eager JS, not search/dataset payload. Lantern, desktop, 1x CPU. Does not forecast fleet p75; do not gate on LCP.

Web-vitals A/B — base (02f8a84) (A) vs pr (e6f6509) (B)

Lighthouse 12.8.2, throttling simulate (cpu 1x, rtt 40 ms, 10240 kbps). Form factor: desktop. Cache: cold (fresh incognito context per run). target n=3/build, 1 warm-up discarded, alternating A,B.

Boot-only (no GMS). Unauthenticated login route — eager JS/CSS/font transfer and parse, not search/dataset payload. Do not treat as a fleet p75.

boot

Measured runs in the table: A 3/3, B 3/3.

metric A p50 B p50 Δ p50 Δ% A p95 B p95
fcp 826 ms 839 ms 14 ms +1.6% 846 ms 845 ms
lcp 1295 ms 1290 ms -5 ms -0.4% 1304 ms 1292 ms
cls 0.0000 0.0000 0.0000 — 0.0000 0.0000
tbt 10 ms 7 ms -2 ms -26.3% 15 ms 8 ms
tti 1296 ms 1291 ms -5 ms -0.4% 1305 ms 1293 ms
ttfb 1 ms 0 ms 0 ms -45.5% 1 ms 1 ms
transferredBytes 1077.1 KB 1077.1 KB -0.0 KB -0.0% 1077.1 KB 1077.1 KB
mainThread 274 ms 246 ms -29 ms -10.4% 281 ms 249 ms
bootup 137 ms 125 ms -13 ms -9.1% 152 ms 126 ms

Resource transfer by type (p50):

type A bytes B bytes Δ bytes A requests B requests
document 1.3 KB 1.3 KB -0.0 KB 1 1
script 645.3 KB 645.3 KB -0.0 KB 8 8
stylesheet 3.0 KB 3.0 KB 0.0 KB 2 2
image 48.7 KB 48.7 KB 0.0 KB 1 1
media 257.3 KB 257.3 KB 0.0 KB 1 1
font 106.6 KB 106.6 KB 0.0 KB 3 3
other 0.0 KB 0.0 KB 0.0 KB 0 0

LCP element A: div > div.sc-fpAkvV > div.sc-pRPz > p.sc-pNWdM — Welcome to DataHub
LCP element B: div > div.sc-fpAkvV > div.sc-pRPz > p.sc-pNWdM — Welcome to DataHub

These numbers rank changes and gate regressions against the measured origin(s). They do not sum across PRs and do not forecast any fleet-wide production number.

@meticulous

meticulous Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Meticulous Agent Swarm

Tested on commit e6f6509.

Pass Re-sorting mixed results keeps all seven cards listed

Re-sorting seven mixed chart and data-source results reversed their order without dropping any cards.

Watch: Re-sorting mixed results keeps the search page usable

Open in Meticulous

This branch was successfully deployed

2 active deployments
Preview — e6f6509f Deployed Dec 4, 2026 by vercel[bot]
datahub-project-web-react (Preview) — e6f6509f Deployed Dec 4, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant