Skip to content

[Detail Bug] Impact Analysis: filtering/search on page >1 can show empty lineage table and hide pagination #32632

Closed

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_3377c26d-da48-4ccd-b83a-22c542f4fe83/bugs/bug_9828dd25-6a18-4b8c-931b-5c94ef722c4f

Introduced in #25353 by @mohityadav766 on Apr 6, 2026

Summary

  • Context: LineageTable.tsx powers the Impact Analysis tab — a paginated table of upstream/downstream lineage nodes/edges that the user can filter via a free-text search box and a set of "quick filters" (service, owner, tags, glossary, ...).
  • Bug: When the user types in the search box or changes a quick filter while sitting on a page other than page 1, the table does NOT reset the current page to 1 before refetching. The next call to the lineage API uses from = (currentPage - 1) * pageSize, which can be far beyond the now‑narrower result set.
  • Actual vs. expected: The fetched from index is preserved across filter/search changes, so the user is shown an empty table whenever the filtered result set has fewer items than (currentPage - 1) * pageSize. Expected: any change to the user's filters/search should re-fetch starting from page 1 of the new result set.
  • Impact: While the filter is applied, an empty NoDataPlaceholder is rendered with no pager at the component default page size, even though matching assets exist on page 1 of the filtered set.

Code with Bug

openmetadata-ui/src/main/resources/ui/src/components/LineageTable/LineageTable.tsx

<CustomControlsComponent
  ...
  searchValue={searchValue}
  onSearchValueChange={setSearchValue} // <-- BUG 🔴 no page reset on search change
/>
const res = await getLineageByEntityCount({
  ...
  from: (currentPage - 1) * pageSize, // <-- BUG 🔴 stale currentPage survives filter/search changes
  size: pageSize,
  ...
});

Column-level mode has the same issue via in-memory slicing:

const source = nodes.slice(
  (currentPage - 1) * pageSize, // <-- BUG 🔴 stale currentPage slices past narrowed node list
  currentPage * pageSize
);

Explanation

  • Pagination is reset to page 1 for impact-level changes and upstream/downstream direction changes, but not for search or quick-filter changes.
  • CustomControlsComponent (which owns the search box and quick filters) is not wired to handlePageChange(1); it only updates filter state (setSearchValue, setSelectedQuickFilters). usePaging does not auto-reset currentPage when paging.total shrinks.
  • Result: on page ≥ 2, narrowing the dataset can make (currentPage - 1) * pageSize exceed the filtered result count.
    • Table-level mode: the stale from is sent to getLineageByEntityCount, and the backend returns a page containing only the root; the UI deletes the root node and ends up rendering an empty table.
    • Column-level mode: the full filtered list is fetched, but the UI slices using the stale currentPage, producing [].
  • At the component’s default pageSize=50, usePaging can set showPagination=false when paging.total < 50, and TableV2 then renders no pagination footer, leaving no in-component way to “stay filtered and go to page 1.”

Codebase Inconsistency

Impact-level and direction changes explicitly reset the page, but search/quick-filter changes do not:

onAction={(key: Key) => {
  flushSync(() => {
    setSelectedImpactLevel(key as EImpactLevel);
  });
  clearQuickFilterValues();
  handlePageChange(1); // <-- resets here
}}
onSelectionChange={(keys: Selection) => {
  const value = [...(keys as Set<LineageDirection>)][0];
  if (value) {
    handlePageChange(1); // <-- resets here
    updateURLParams({ dir: value });
  }
}}

Failing Test

A Jest repro (using real usePaging) demonstrates the bug by showing from is not reset when searchValue changes while seeded to currentPage=3&pageSize=10:

it('▶ STALE-OFFSET REPRO: real usePaging keeps currentPage across a search change (seeded URL currentPage=3)', async () => {
  const realUsePaging =
    (jest.requireActual('../../hooks/paging/usePaging') as {
      usePaging: typeof usePaging;
    }).usePaging;
  mockUsePaging.mockImplementation(realUsePaging);

  (
    getSearchNameEsQuery as jest.MockedFunction<typeof getSearchNameEsQuery>
  ).mockImplementation((searchText: string) => ({
    bool: {
      should: [
        { wildcard: { 'name.keyword': { value: `*${searchText}*` } } },
        { wildcard: { 'displayName.keyword': { value: `*${searchText}*` } } },
      ],
    },
  }));

  mockUseLineageTableState.mockReturnValue({
    ...defaultMockState,
    impactLevel: EImpactLevel.TableLevel,
    searchValue: '',
    setFilterNodes: jest.fn(),
  });

  const { rerender } = render(<LineageTable entity={mockEntity} />, {
    wrapper: ({ children }) => (
      <MemoryRouter initialEntries={['/test?currentPage=3&pageSize=10']}>
        {children}
      </MemoryRouter>
    ),
  });

  await waitFor(() => {
    expect(mockGetLineageByEntityCount).toHaveBeenCalledWith(
      expect.objectContaining({ from: 20, size: 10 })
    );
  });

  mockGetLineageByEntityCount.mockClear();

  mockUseLineageTableState.mockReturnValue({
    ...defaultMockState,
    impactLevel: EImpactLevel.TableLevel,
    searchValue: 'narrow',
    setFilterNodes: jest.fn(),
  });
  rerender(<LineageTable entity={mockEntity} />);

  await waitFor(() => {
    expect(mockGetLineageByEntityCount).toHaveBeenCalledWith(
      expect.objectContaining({ from: 20, size: 10 })
    );
  });
  expect(
    JSON.stringify(mockGetLineageByEntityCount.mock.calls[0][0].query_filter ?? '')
  ).toContain('narrow');
});

Test output:

PASS @openmetadata src/components/LineageTable/LineageTable.test.tsx (8.401 s)
  fetchNodes - Table Level Impact
    ✓ ▶ STALE-OFFSET REPRO: real usePaging keeps currentPage across a search change (seeded URL currentPage=3) (62 ms)
Tests:       37 passed, 37 total

Recommended Fix

Reset to page 1 in the same handler that updates search/quick-filter state (not a separate useEffect). Example for search:

const handleSearchValueChange = useCallback(
  (value: string) => {
    handlePageChange(1);
    setSearchValue(value);
  },
  [handlePageChange, setSearchValue]
);

Apply the same pattern for quick-filter changes/clears so both table-level and column-level modes reset currentPage before the next fetch/slice.

History

This bug was introduced in commit 7bb8e40. The change ("Fix column filtering on Lineage", #25353) rewired the Impact Analysis search box to always call setSearchValue (expanding search to column-level) without adding a page reset, so filtering/searching on page ≥ 2 now uses a stale offset.

Activity

  1. added a commit that references this issue on Sep 10, 2026
    f1c3f22
  2. added a commit that references this issue on Sep 11, 2026
    e00037a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions