Repository navigation
In review
Description
Detail Bug Report
Introduced in #36006 by @Rohit0301 on Oct 23, 2026
Summary
- Context:
useUserAssetsListpowers the search/filterable asset list in the User Assets panel (UserAssetsView) on the user profile page, paging results from the search API and guarding against slow/duplicated responses. - Bug: When the search text or type filter changes, the hook resets its list state during render but only bumps the stale-response counter (
requestRef) later insidefetchPage, which runs in a passive effect — so a response belonging to the previous search/filter that settles in the window between the reset commit and the effect still passes theisCurrent()guard and commits stale data. - Actual vs. expected: The hook's own documented invariant is "Only the latest request may write state, so a slow earlier page or search can't overwrite a newer one", and the reset is meant to show "a loader rather than 'no match'" until the new query's results arrive — instead, the cleared list is repopulated with the previous query's hits; if a Load-more is then triggered from the stale frame, the load-more request is issued with the new query but the stale page number, and its newer request id causes the correct in-flight page-1 response to be discarded, leaving the panel showing the previous query's results mixed with wrong-page results of the new query until the user searches again.
- Impact: The user assets panel renders wrong assets for the user's current search/filter — transiently in the plain case, where the new query's page-1 response replaces the stale list once it lands; in the load-more variant, the corrupted mixed list (previous query's pages + new query's wrong page) with an inconsistent total does not self-correct, and only a further search/filter change can recover it.
Code with Bug
openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/UserAssets/useUserAssetsList.ts
// Clear the previous list during render, so the frame before the new
// request starts shows a loader rather than "no match".
const listKey = `${kind}|${ownerIdsKey}|${search}|${indexes.join(',')}`;
const [prevListKey, setPrevListKey] = useState(listKey);
if (prevListKey !== listKey) {
setPrevListKey(listKey);
setPage(1);
setAssets([]);
setError(undefined);
setIsLoading(true);
// <- BUG 🔴 requestRef.current is NOT bumped here, so prior in-flight responses still look "current"
} const fetchPage = useCallback(
async (pageNumber: number) => {
// Only the latest request may write state, so a slow earlier page or
// search can't overwrite a newer one.
const requestId = ++requestRef.current; // <- BUG 🔴 only bump occurs here (passive effect), after the reset commit
const isCurrent = () => requestId === requestRef.current;
...
if (!isCurrent()) {
return;
}
...
setAssets((prev) =>
pageNumber === 1 ? hits : uniqBy([...prev, ...hits], 'id')
);
setPage(pageNumber);Explanation
- The hook resets state when
listKeychanges during render, but the nextfetchPage(1)is started from auseEffect. Between the reset commit and the effect running, an older in-flight request (for the previouslistKey) can resolve. - Because the reset does not invalidate in-flight work (
requestRef.currentis unchanged), the old response still satisfiesisCurrent()and writesassets/page/total/isLoading, repopulating the cleared list with stale results. - If a load-more is triggered from that stale state, it can compute the next page from the stale
pagewhile using the new query params, causing wrong-page results for the new query to be appended; the newer request id then causes the correct page-1 response for the new query to be discarded.
Recommended Fix
Invalidate pre-reset requests when the reset runs so any response from the previous listKey becomes non-current:
if (prevListKey !== listKey) {
setPrevListKey(listKey);
requestRef.current += 1; // <-- FIX 🟢 invalidate pre-reset in-flight responses
setPage(1);
setAssets([]);
setError(undefined);
setIsLoading(true);
}History
This bug was introduced in commit df19bff (PR #36006), which added the User Assets feature and the useUserAssetsList hook with a render-phase reset and a request counter bumped only when the effect-started fetch begins.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsNo status
Activity