Repository navigation
fix(search): key search results by urn so a re-sort does not crash the page - #21909
v-tarasevich-blitz-brain wants to merge 1 commit into
Conversation
PR SummaryOverview 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. |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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>
Smart test selectionPlaywright E2E testsThis run:
Specs selected because of this PR (8)
Add the commit |
i18n locale parityStatus:
Per-key detail is in the job summary of the ./gradlew :datahub-web-react:yarnI18nParityCheck # all locales
cd datahub-web-react && yarn check-i18n-parity --lang de # one locale |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Bundle ReportChanges will increase total bundle size by 23 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: datahub-react-web-esmAssets Changed:
Files in
|
|
✅ 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 |
Initial JS bundle size ➡️
|
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.
|
| 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 Agent Swarm
Tested on commit
|


Problem
The search results list (
app/searchV2/SearchResultList.tsx) renders an antdListwithout arowKey. 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
rowKey={(item) => item.entity.urn}to theListinSearchResultList. Each entity gets its own card, so one card instance never renders two different entities. Search results are unique by urn.The same change is in DataHub Cloud, so this keeps OSS and DataHub Cloud aligned.
Verification
yarn type-checkpasses.eslintandprettier --checkpass 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
ListinSearchResultListnow 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.