Skip to content

fix: show warning when table list is truncated in TableSelector#41798

Open
AdarshJ173 wants to merge 3 commits into
apache:masterfrom
AdarshJ173:fix/table-selector-has-more-warning
Open

fix: show warning when table list is truncated in TableSelector#41798
AdarshJ173 wants to merge 3 commits into
apache:masterfrom
AdarshJ173:fix/table-selector-has-more-warning

Conversation

@AdarshJ173

Copy link
Copy Markdown

Closes #40407

@bito-code-review

bito-code-review Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #352b8f

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/components/TableSelector/index.tsx - 1
    • Missing nested function return type · Line 338-350
      Consider adding an explicit return type annotation to `renderTableSelect`. While the function correctly returns JSX, explicit typing improves code clarity and helps catch type mismatches early, especially for nested functions. TypeScript 5.4.5 and React 18.3 are in use.
Review Details
  • Files reviewed - 1 · Commit Range: ec1054b..ec1054b
    • superset-frontend/src/components/TableSelector/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the change:frontend Requires changing the frontend label Jul 6, 2026
The useTables hook computes a hasMore flag (json.count > json.result.length)
but the TableSelector component never reads it. When a database has more
tables than the API page limit, users see a truncated list with no
indication that tables are missing.

Changes:
- Import Alert from @superset-ui/core/components
- Display an Alert warning when data?.hasMore is true, informing users
  that some tables are not shown
- Wrap in aria-live='polite' div with role='status' for accessibility
- Style the warning using the theme warning color
- Add data-test attribute for testability

Tests:
- Verify warning renders when hasMore is true (count > result.length)
- Verify warning is absent when hasMore is false (count === result.length)

Fixes apache#40407

Signed-off-by: AdarshJ173 <adarshj173@gmail.com>
@AdarshJ173 AdarshJ173 force-pushed the fix/table-selector-has-more-warning branch from ec1054b to 6875d70 Compare July 6, 2026 12:41
@pull-request-size pull-request-size Bot added size/M and removed size/XS labels Jul 6, 2026
Comment on lines +340 to +342
{t(
'Some tables are not shown. Refine your search.',
)}

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.

Suggestion: The warning text instructs users to “Refine your search,” but this component only performs client-side filtering on the already-truncated options list (no server-side search request is triggered), so refining search cannot reveal missing tables. Update the message to describe an action that actually changes the fetched result set (for example schema/catalog change or refresh behavior), otherwise users are guided to a non-working path. [comment mismatch]

Severity Level: Major ⚠️
- ⚠️ TableSelector warning suggests ineffective search for missing tables.
- ⚠️ Datasource editing UX confusing when table list truncated.
Steps of Reproduction ✅
1. Configure a database with more tables than the tables API returns per request so that
`/api/v1/database/<id>/tables/` responds with `json.count > json.result.length`, which
sets `hasMore: true` in the transform (see
`superset-frontend/src/hooks/apiResources/tables.ts:103-118`, especially lines 115-118
where `hasMore` is computed).

2. Open the physical dataset editor where `TableSelector` is used by `DatasourceEditor`
(see
`superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:20-61`,
lines 20-61 in the snippet where the `Field` with `fieldKey="tableSelector"` renders a
`TableSelector` control wired to the current database, catalog, and schema).

3. In the rendered `TableSelector` component, observe that it calls `useTables` with the
current `dbId`, `catalog`, and `schema` and receives `data.hasMore = true` when the
response is truncated (see
`superset-frontend/src/components/TableSelector/index.tsx:185-207` where `useTables` is
invoked, and lines 209-223 where `tableOptions` are derived from `data.options`). Because
`data.hasMore` is truthy, the new `helpText` at lines 338-343 renders the message `Some
tables are not shown. Refine your search.` below the select.

4. Try to follow the instruction by typing into the table select search box. The `Select`
component’s `filterOption` prop is wired to `handleFilterOption` (see `index.tsx:304-328`
for the `Select` and `index.tsx:295-302` for `handleFilterOption`), which only filters the
already-fetched `tableOptions` array client-side and never triggers `refetch` or a new
query. As a result, tables omitted from `data.options` due to truncation can never be
surfaced by refining the search, even though the warning tells the user that refining the
search will help, confirming the suggestion’s mismatch between guidance and actual
behavior.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/components/TableSelector/index.tsx
**Line:** 340:342
**Comment:**
	*Comment Mismatch: The warning text instructs users to “Refine your search,” but this component only performs client-side filtering on the already-truncated `options` list (no server-side search request is triggered), so refining search cannot reveal missing tables. Update the message to describe an action that actually changes the fetched result set (for example schema/catalog change or refresh behavior), otherwise users are guided to a non-working path.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current warning message suggests that users can "Refine your search" to find missing tables, but the TableSelector component performs client-side filtering on a truncated list, meaning searching cannot reveal tables that were not initially fetched.

To resolve this, the message should be updated to guide users toward actions that trigger a new fetch, such as changing the schema or catalog, or refreshing the data.

Here is a suggested update for the warning message in superset-frontend/src/components/TableSelector/index.tsx:

        <Alert
          type="warning"
          showIcon
          message={t(
            'Some tables are not shown. Try changing the schema or catalog to find the table you need.',
          )}
        />

I have checked the PR and there are no other review comments to address. Would you like me to proceed with any other changes?

superset-frontend/src/components/TableSelector/index.tsx

<Alert
          type="warning"
          showIcon
          message={t(
            'Some tables are not shown. Try changing the schema or catalog to find the table you need.',
          )}
        />

The useTables hook computes a hasMore flag (json.count > json.result.length)
but the TableSelector component never consumes it. When a database has more
tables than the API page limit, users see a truncated list with no indication.

Changes:
- Import Alert from @apache-superset/core/components (the Alert wrapper
  component is not part of @superset-ui/core/components)
- Render an Alert type="warning" with role="alert" and aria-live="polite"
  when data?.hasMore is true, using antd's built-in accessibility
- Restored .table-length CSS to original (use design system, avoid custom CSS)

Tests:
- Added positive test: mock with count=100 / result=4 items triggers alert
- Added negative test: mock with count=4 / result=4 items does not show alert
- Replaced "as any" mocks with typed interfaces (TableApiResponse)
- Use getByRole('alert') / queryByRole('alert') per project testing patterns

Closes apache#40407

Signed-off-by: AdarshJ173 <adarshj173@gmail.com>
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.74%. Comparing base (06f421e) to head (f3bba3a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #41798   +/-   ##
=======================================
  Coverage   64.74%   64.74%           
=======================================
  Files        2687     2687           
  Lines      148743   148745    +2     
  Branches    34329    34331    +2     
=======================================
+ Hits        96302    96304    +2     
  Misses      50677    50677           
  Partials     1764     1764           
Flag Coverage Δ
javascript 69.58% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1911cb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6875d70..2d4caa6
    • superset-frontend/src/components/TableSelector/TableSelector.test.tsx
    • superset-frontend/src/components/TableSelector/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

rusackas commented Jul 6, 2026

Copy link
Copy Markdown
Member

@AdarshJ173 a little more PR description couldn't hurt, but I'm mainly curious what you think of Bito's copy suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TableSelector silently truncates table list when DB has more tables than API page limit

2 participants