Repository navigation
Conversation
Code Review Agent Run #1e759eActionable Suggestions - 0Additional Suggestions - 1
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| const remainingRows = | ||
| rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize; | ||
|
|
||
| moreProps.row_limit = |
There was a problem hiding this comment.
🟠 Architect Review — HIGH
When server pagination is enabled, the filter-change reset block persists the dynamic, last-page-capped queryObject.row_limit into ownState.pageSize, so if an external filter changes while the user is on the final page, the server pagination page size silently shrinks to the remainder instead of staying at the user-selected/server_page_length value.
Suggestion: Decouple "selected page size" from the per-request row_limit: on filter-change reset, set pageSize back to the configured server page length or the existing ownState.pageSize, and only apply the remaining-rows cap to queryObject.row_limit when building the query so that ownState.pageSize is never overwritten with a remainder-sized value.
Fix in Cursor | Fix in VSCode Claude
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
**Path:** superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
**Line:** 240:276
**Comment:**
*HIGH: When server pagination is enabled, the filter-change reset block persists the dynamic, last-page-capped `queryObject.row_limit` into `ownState.pageSize`, so if an external filter changes while the user is on the final page, the server pagination page size silently shrinks to the remainder instead of staying at the user-selected/server_page_length value.
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.
If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
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|
The flagged issue is correct. The current implementation in the diff incorrectly calculates Here is the corrected implementation: const pageSize = Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
const currentPage = Number(ownState.currentPage) || 0;
const rowOffset = currentPage * pageSize;
const rowLimit = Number(formDataCopy.row_limit) || 0;
moreProps.row_limit = rowLimit > 0 ? Math.min(pageSize, Math.max(rowLimit - rowOffset, 0)) : pageSize;
moreProps.row_offset = rowOffset;This ensures superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts |
| const remainingRows = | ||
| rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize; | ||
|
|
||
| moreProps.row_limit = | ||
| rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize; |
There was a problem hiding this comment.
Suggestion: When rowOffset exceeds row_limit, remainingRows becomes 0 and the new logic assigns moreProps.row_limit = 0. In Superset query objects, row_limit: 0 means "no limit", not "return zero rows", so this can accidentally remove the cap and return rows beyond the configured row limit. Clamp the page/offset to a valid range or handle the zero-remaining case without emitting an unlimited row_limit. [logic error]
Severity Level: Major ⚠️
- ❌ Table server pagination can bypass configured row limit cap.
- ⚠️ Extra rows increase query load and confuse chart users.Steps of Reproduction ✅
1. Render a Table chart with server pagination enabled so form data includes
`server_pagination: true` and `server_page_length`, as wired in
`superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx:383-405`. The chart is
rendered by `TableChart.tsx` which passes `serverPaginationData` (taken from
`chartProps.ownState`, see `transformProps.ts:499` and `transformProps.ts:778-790`) into
the `DataTable` component.
2. Navigate to a later page using the server-side pagination controls. Clicking a page in
the pagination UI calls `onServerPaginationChange`, which in Table charts is implemented
by `handleServerPaginationChange` in `TableChart.tsx:1458-1466` to update
`ownState.currentPage` and `ownState.pageSize` via `updateTableOwnState`. The next query
run uses this persisted `ownState` as `options.ownState` when `buildQuery` in
`buildQuery.ts` is invoked.
3. While on a later page, lower the chart Row limit to a value smaller than the current
offset (e.g. previously `row_limit = 1000`, `server_page_length = 50`, `currentPage = 4`,
then change `row_limit` to `10` and rerun). There is no code that resets `currentPage` on
row-limit changes: `cachedBuildQuery` in `buildQuery.ts:267-279` only resets
`row_offset`/`currentPage` when filters change, and `TableChart.tsx` only resets
`currentPage` on server page length changes (`useEffect` at `TableChart.tsx:31-38`) or
search changes (`handleSearch` at `TableChart.tsx:74-80`). Thus
`options.ownState.currentPage` can remain > new last page when the new query is built.
4. On the next data load, `buildQuery` computes the main page query with the stale
`currentPage`. In `buildQuery.ts:231-243`, it derives `pageSize` and `rowOffset` from
`ownState` and server page length, then calculates:
- `rowOffset = currentPage * pageSize`
- `rowLimit = Number(formDataCopy.row_limit) || 0`
- `const remainingRows = rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize;`
(line 237)
- `moreProps.row_limit = rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize;`
(line 241)
When `rowOffset >= rowLimit` (e.g. `row_limit = 10`, `pageSize = 50`, `currentPage =
2`, so `rowOffset = 100`), `remainingRows` becomes `0`, and `moreProps.row_limit` is
set to `0`. In Superset query objects a `row_limit` of `0` is used as "no limit" / "all
records" (see the same file's extra queries with `row_limit: 0` at
`buildQuery.ts:113-120` and the test expectation in
`plugins/plugin-chart-table/test/buildQuery.test.ts:18-26` for
`percent_metric_calculation: 'all_records'`). Thus this path emits a main data query
with `row_offset > 0` and `row_limit = 0`, effectively removing the chart row limit cap
for that request and allowing more than the configured `row_limit` rows to be returned.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/plugins/plugin-chart-table/src/buildQuery.ts
**Line:** 237:241
**Comment:**
*Logic Error: When `rowOffset` exceeds `row_limit`, `remainingRows` becomes `0` and the new logic assigns `moreProps.row_limit = 0`. In Superset query objects, `row_limit: 0` means "no limit", not "return zero rows", so this can accidentally remove the cap and return rows beyond the configured row limit. Clamp the page/offset to a valid range or handle the zero-remaining case without emitting an unlimited `row_limit`.
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
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #41024 +/- ##
==========================================
- Coverage 64.31% 55.62% -8.69%
==========================================
Files 2652 2652
Lines 144799 144810 +11
Branches 33415 33423 +8
==========================================
- Hits 93122 80550 -12572
- Misses 50016 63533 +13517
+ Partials 1661 727 -934
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review Agent Run #e0ff53Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rusackas
left a comment
There was a problem hiding this comment.
Code LGTM — clamping row_limit to the remaining rows inside the user's row_limit is the right fix, and the Number(...) || 0 guards read well. Thanks for the two buildQuery tests covering both the lower-limit and remaining-rows cases. Happy to merge once CI's green.
Address two issues in the server-pagination row-limit capping: - Pages beyond the row limit made remainingRows 0, so row_limit collapsed to 0, which the backend treats as 'no limit' and returns all rows. Clamp the requested page to the last one within the limit so the cap holds. - On filter-change reset, ownState.pageSize was persisted from the capped per-request row_limit, silently shrinking page size on the last page. Persist the user-selected page size instead. Co-Authored-By: Claude <[email protected]>
|
Thanks @innovark37! Circled back because the codeant bot flagged a couple things, and it was actually right on both this time. When the requested page sits past the configured row limit, I pushed a fix to clamp the page to the last one inside the limit and persist the user-selected page size instead, plus a test for the row_limit:0 case. Left the rest of your logic intact. Should be good once CI's green, but holler if you'd rather take a different tack on the clamp. |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| const remainingRows = | ||
| rowLimit > 0 ? Math.max(rowLimit - rowOffset, 0) : pageSize; | ||
|
|
||
| moreProps.row_limit = | ||
| rowLimit > 0 ? Math.min(pageSize, remainingRows) : pageSize; | ||
| moreProps.row_offset = rowOffset; |
There was a problem hiding this comment.
Suggestion: row_limit is now page-dependent, but when cached filters change the code only resets row_offset to 0 and does not recompute row_limit. If the user was on a capped last page (for example row_limit=120, pageSize=50, page 3 -> row_limit=20), the reset query for page 1 will still request only 20 rows instead of 50. Recompute row_limit after forcing offset/page reset (or rebuild pagination props using page 0) so first-page fetch size is correct after filter changes. [logic error]
Severity Level: Major ⚠️
- ⚠️ First page after filter changes returns fewer rows.
- ⚠️ Table chart server pagination inconsistent with configured page size.Steps of Reproduction ✅
1. Open or create a Table chart that uses the Table plugin (registered in
`superset-frontend/plugins/plugin-chart-table/src/index.ts:19-61`) and enable server
pagination in the control panel (`server_pagination` and `server_page_length` controls in
`src/controlPanel.tsx:383-407`).
2. Configure a `row_limit` that is not a multiple of the server page length, for example
`row_limit = 120` and `server_page_length = 50`. Load data and navigate to the last server
page via the table pagination UI, which updates `ownState.currentPage` through
`handleServerPaginationChange` in `src/TableChart.tsx:24-32` by calling
`updateTableOwnState` with `currentPage` set to the selected page.
3. With the chart currently on that last page (so the previous request used `row_offset =
100` and a capped `row_limit = 20` computed in `buildQuery` at
`src/buildQuery.ts:231-251`), change an external filter (e.g., a dashboard filter or
cross-filter) so that `queryObject.filters` differs from the cached filters stored via
`setCachedChanges` (`src/buildQuery.ts:51-54` and the closure in `cachedBuildQuery` at
`src/buildQuery.ts:124-141`).
4. When the new request is built, `buildQuery` recomputes `moreProps` using the stale
`ownState.currentPage` (still pointing at the last page) and sets `moreProps.row_limit =
20` and `moreProps.row_offset = 100` (`src/buildQuery.ts:241-251`). The subsequent
filter-change block (`src/buildQuery.ts:96-103`) only overrides `row_offset` back to `0`
and does not recompute `row_limit`, so the first-page query after the filter change is
sent with `row_limit = 20` instead of the expected full page size `50`, yielding an
incorrectly short first page.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
**Line:** 246:251
**Comment:**
*Logic Error: `row_limit` is now page-dependent, but when cached filters change the code only resets `row_offset` to 0 and does not recompute `row_limit`. If the user was on a capped last page (for example `row_limit=120`, `pageSize=50`, page 3 -> `row_limit=20`), the reset query for page 1 will still request only 20 rows instead of 50. Recompute `row_limit` after forcing offset/page reset (or rebuild pagination props using page 0) so first-page fetch size is correct after filter changes.
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…ination The filter-change reset zeroed row_offset but kept the last page's capped row_limit, so the first page after a filter change fetched fewer rows than the configured page size. Restore the full first-page row_limit on reset. Also export buildQuery for direct testing and add coverage for the full server-pagination/row-limit matrix: user limit below page size, capped last page, pages clamped past the limit (no row_limit: 0), first-page restore and page-size persistence on filter reset, and the no-row-limit fallback. Co-Authored-By: Claude <[email protected]>
|
Yeah, the bot caught a third real one, same root cause: on a filter reset we zeroed the offset but kept the last page's capped Rather than keep whacking these one at a time, I exported |
|
Now that this has my fingerprints all over it, let me know your thoughts, I don't want to just randomly merge my own work. Adding @sadpandajoe for another pair of eyes here. |
There was a problem hiding this comment.
Code Review Agent Run #f34659
Actionable Suggestions - 2
-
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts - 2
- Large duplicated code block (204 tokens) · Line 57-57
- Small duplicated code block (72 tokens) · Line 230-230
Review Details
-
Files reviewed - 2 · Commit Range:
139904f..da60ea1- superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts
- superset-frontend/plugins/plugin-chart-table/test/buildQuery.test.ts
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ 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 [email protected].
Documentation & Help
| } | ||
|
|
||
| const buildQuery: BuildQuery<TableChartFormData> = ( | ||
| export const buildQuery: BuildQuery<TableChartFormData> = ( |
There was a problem hiding this comment.
Code duplication detected: 31 lines of buildQuery implementation are duplicated between plugin-chart-table/src/buildQuery.ts (lines 57-87) and plugin-chart-ag-grid-table/src/buildQuery.ts (lines 61-91). Additional similar duplications exist at lines 182-221, 230-244, and 278-290 in plugin-chart-table and corresponding lines in plugin-chart-ag-grid-table. Consider extracting the common buildQuery logic into a shared utility module.
Code Review Run #f34659
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
| const firstPageRowLimit = | ||
| configuredRowLimit > 0 | ||
| ? Math.min(pageSize, configuredRowLimit) | ||
| : pageSize; |
There was a problem hiding this comment.
Duplicate code identified: 15 lines of ownState handling and isDownloadQuery detection logic duplicated between plugin-chart-table/src/buildQuery.ts (lines 230-244) and plugin-chart-ag-grid-table/src/buildQuery.ts (lines 205-219). This is part of a larger pattern of duplication in these buildQuery implementations.
Code Review Run #f34659
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
I think the CodeAnt logic comments here are already handled by your last couple commits (the |
Co-authored-by: Evan Rusackas <[email protected]> Co-authored-by: Claude <[email protected]>
Ports the server-pagination row-limit fix from plugin-chart-table (#41024) to the ag-grid table, which shared the same buildQuery logic and therefore the same bugs: - Paging past the configured row limit produced `row_limit: 0`, which the backend treats as "no limit" rather than "no rows" — silently removing the cap and returning more rows than configured. The page is now clamped to the last page that still falls within the limit, and per-page `row_limit` is capped to the remaining rows. - On a filter-change reset the per-request (last-page-capped) `row_limit` was persisted into `ownState.pageSize`, shrinking the page size. The reset now restores the full first-page `row_limit` and persists the user-selected page size. Adds unit tests mirroring the plugin-chart-table coverage. Co-Authored-By: Claude Opus 4.8 <[email protected]>
SUMMARY
Fixes Table chart server pagination so the main data query respects the configured row limit.
When Table chart server pagination is enabled, Superset runs separate queries for the current page data and for the total row count. The row count query already uses the configured Row limit, but the current page data query used only the Server Page Length.
This could make the table preview show more rows than the configured Row limit allows. The fix makes the current page data query cap its page size by the remaining rows within the Row limit.
For example:
row_limit = 120,server_page_length = 50showed 3 pages, but the last page could request 50 rows instead of the remaining 20.row_limit = 10,server_page_length = 20could display 20 rows in preview even though the chart row limit was 10.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
50.120.10and Server Page Length to20.ADDITIONAL INFORMATION