Repository navigation
fix(ui): reliably refresh teams list after create (fixes flaky Teams breadcrumb E2E) - #34619
Conversation
The all-teams advanced fetch (parentTeam=...&fields=...) rode a boolean flag: fetchAllTeamsBasicDetails set it true, an effect fired the fetch on the flip, and the fetch reset it to false. When a refresh was requested while a prior advanced fetch was still in flight (slow under load), the boolean was already true, so the write was a no-op, the effect never re-ran, and the refresh was silently dropped. Split the single boolean into a monotonic nonce (trigger) and a dedicated loading flag. Each basic-fetch completion bumps the nonce, so the effect always re-fires even while a prior fetch is in flight. The loading flag keeps driving the hierarchy count skeletons. Fixes the flaky Teams breadcrumb Playwright test (the awaited teams-list GET was never sent) and the underlying bug where creating a team while counts were still loading left the new row's counts stale.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 3428 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 55m 31s ⏱️ Max setup 5m 4s · max shard execution 20m 26s · max shard-job elapsed before upload 23m 38s · reporting 12s 🌐 213.15 requests/attempt · 2.02 app boots/UI scenario · 37.77% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Address review feedback on the nonce change: - Overlapping full refreshes: the nonce lets a newer advanced fetch start before an older one resolves. Tag each full refresh (updateChildNode=false) with a request id and only let the latest apply its list and clear the loading flag, so a slow pre-create response can no longer overwrite the list with stale data or hide the count skeletons early. Expand calls merge into a specific subtree and skip the request-id bump, so they don't invalidate each other. - Duplicate fetch on navigation: keying the effect on both the nonce and fqn fired the advanced GET twice per navigation (once from fqn, once from the following nonce bump). Trigger on the nonce alone and read the latest fqn through a ref.
- cyclomatic-complexity (error): the previous helper only touched the map callback (a separate function), so fetchAllTeamsAdvancedDetails stayed at 11. Extract the result-application branch into applyAllTeamsData, dropping two decision points from the function (now 9). - exhaustive-deps (warnings): add the stable t to the two useCallback dep arrays that use it; annotate the three trigger effects with justified eslint-disable-next-line (their fetchers are non-memoized triggers, not reactive inputs — adding them would re-run every render or duplicate the navigation fetch).
The nonce refactor set isFetchAllTeamAdvancedDetails(true) at the start of every advanced fetch, including expand (updateChildNode=true). That flag drives the per-column skeletons across all rows in TeamHierarchy, so expanding one row blanked the whole table. Restore the original behavior: set the flag only for full refreshes (setIsFetchAllTeamAdvancedDetails( isFullRefresh)); expand leaves it off.
setIsFetchAllTeamAdvancedDetails(isFullRefresh) still wrote false on expand, and the finally cleared it too (isLatestFullRefresh is always true for expands) — so expanding a row while a full refresh is mid-flight hid the count skeletons early and showed stale values. Guard both the set and the clear on full-refresh-only: set behind if (isFullRefresh); clear behind a new isActiveFullRefresh() (isFullRefresh && latest). The && lives in a nested arrow so cyclomatic-complexity stays at 10.
Overlap two full refreshes (mount + showDeleted toggle), resolve the newer one first and the older (stale) one last, and assert the stale response does not overwrite the list. Verified it fails without the request-id guard in fetchAllTeamsAdvancedDetails. Extends the TeamDetailsV1 mock to render childTeams names so the applied list is observable.
Replace the three disable directives with real fixes: - Move updateTeamsHierarchy to module scope (pure, no closure); convert applyAllTeamsData, fetchAllTeamsAdvancedDetails, fetchAllTeamsBasicDetails, getParentTeam, and fetchTeamBasicDetails to useCallback with honest dep arrays so their identities are stable. - fetchAllTeamsBasicDetails now chains the advanced fetch directly (void call) instead of bumping a nonce through an effect — removes the nonce state, fqnRef, and the two associated effects entirely. - The team-list effect depends on [fqn, hasViewPermission, fetchAllTeamsBasicDetails]: fqn/permission changes trigger navigation refetches; fetchAllTeamsBasicDetails identity changes when showDeletedTeam flips (it closes over it), so the deleted-toggle refetch works without a dedicated effect. - The team-details effect now lists all deps honestly: [hasViewPermission, fqn, fetchTeamBasicDetails, loadAdvancedDetails]. - applyAllTeamsData uses a functional setChildTeams updater on the expand path so it doesn't close over childTeams and can stay stable. - createNewTeam explicitly refreshes the list after a create (void fetchAllTeamsBasicDetails) since navigation/toggle no longer cover it. No behaviour change. 13/13 tests pass. Zero eslint-disable lines remain.
…ponses A basic fetch from a previous fqn could resolve late, overwrite the list with the old parent's teams, and chain an advanced fetch that bumps advancedFetchIdRef — causing the in-flight advanced fetch for the current fqn to be dropped as superseded. Add basicFetchIdRef alongside advancedFetchIdRef and drop the response (and the chained advanced call) if a newer basic fetch has already started.
Code Review ✅ Approved 4 closed / 4 findings🟡 Medium risk · Team creation and navigation now trigger guarded asynchronous list refreshes. Fixes the flaky Teams breadcrumb E2E by replacing a boolean flag with a monotonic nonce to reliably trigger the advanced teams fetch after create operations. Resolved overlapping advanced fetches overwriting the list with stale data, duplicate fetches on fqn changes, expand operations clearing the full-refresh skeleton flag mid-flight, and stale basic fetch responses after navigation. No issues found. ✅ 4 closed✅ Bug: Overlapping advanced fetches can overwrite list with stale data
✅ Performance: fqn change now fires a duplicate advanced teams fetch
✅ Bug: Expand fetch clears full-refresh skeleton flag mid-flight
✅ Edge Case: Stale basic fetch after navigation can replace list with old parent's teams
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|



Problem
Screen.Recording.2026-10-05.at.11.32.29.AM.mov
The Playwright test "Teams Page › Verify breadcrumb navigation for a team with a dot in its name" intermittently times out at the first
addTeamHierarchy(utils/team.ts:442), waiting forGET /api/v1/teams?parentTeam=…&fields=owns,childrenCount,userCount,parents,defaultPersona. The trace shows that GET is never sent — it is a frontend race, not a slow backend, which is why it only fails under parallel load.Root cause
In
TeamsPage.tsxthe "advanced" all-teams fetch (thefields=…GET) was never called directly — it rode a boolean flag:fetchAllTeamsBasicDetailssuccess →setFetchAllTeamAdvancedDetails(true)truefetchAllTeamsAdvancedDetailsfinally→setFetchAllTeamAdvancedDetails(false)On mount the page already runs one basic→advanced cycle. Under parallel load that initial advanced GET is slow, so the flag is still
truewhen the user submits the new team.createNewTeam→loadAdvancedDetails→fetchAllTeamsBasicDetailssets the flagtruewhile it is alreadytrue→ React bails on the no-op write → the effect never re-runs → the post-create refresh is swallowed. The test waits for a request that is never sent → 60s wall.This is also a real product bug: creating a team while the page is still loading counts leaves the new row's
userCount/childrenCountstale until the next navigation.Fix
Split the one boolean that was doing two jobs:
advancedFetchNonce, so the effect always re-fires — even while a prior advanced fetch is in flight. No more coalescing.isFetchAllTeamAdvancedDetailsboolean (set at the start/finally of the advanced fetch) keeps driving the hierarchy count skeletons inTeamHierarchy.No test change needed — the
fields=…GET now reliably fires after every create, so the existing wait inaddTeamHierarchystops hanging.Tests
Teams.spec.tsbreadcrumb-with-dot) by removing its root cause; behaviour for mount andshowDeletedTeamtoggle is unchanged (nonce0 → 1→ single advanced fetch, as before).parentTeam=…&fields=…GET firing after each create.