You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "NoiceHax (via GitHub)" <gi...@apache.org> on 2026/08/14 05:07:55 UTC
[PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
NoiceHax opened a new pull request, #43150:
URL: https://github.com/apache/superset/pull/43150
DataTable returned early when it had no columns, but five hooks (the
mounted ref and its effect, the RAF and signature refs, and the effect
that emits filtered rows through onFilteredRowsChange) were declared
about 130 lines below that return. A table chart whose query result
moves between a columns-less and a populated result therefore changed
its hook count between renders, so React threw "Rendered fewer/more
hooks than expected" and the chart unmounted to an error boundary. Move
those five hooks above the early return and lift stableRowKey,
hashString and signatureOfRows to module scope; no hook body, dependency
array or emit condition changes.
## Testing
New file superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx with two tests that render DataTable inside a class error boundary and rerender across the column-count boundary in both directions (N columns -> 0, and 0 -> N), asserting no render-phase throw and that the expected content renders. Follows the existing error-boundary-in-test precedent from plugins/plugin-chart-calendar/test/ReactCalendar.test.tsx and includes the ASF license header.
Tests are included but I was not able to execute the suite locally (environment not available); please rely on CI.
Closes #42978
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5296869594
### <span aria-hidden="true">โ
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">๐จ</span> Latest commit | 0038bd1bc60098615852323b64ec1d5ea15b871a |
|<span aria-hidden="true">๐</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a7f5f98a816d00008ebb61a |
|<span aria-hidden="true">๐</span> Deploy Preview | [https://deploy-preview-43150--superset-docs-preview.netlify.app](https://deploy-preview-43150--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">๐ฑ</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">๐ค</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84AstMyK_Qzi4tLU3VNjCzNLYBSKakFOfmVnilASbNE8zTTNEuLRAtDsxQDILBITUoyM0xUqgUA) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-43150--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5289748283
<!-- Bito Reply -->
The flagged issue is correct. The `RenderErrorBoundary` component renders a `div` with `data-test="render-error"` (line 266), but the tests attempt to query it using `screen.queryByTestId('render-error')` (lines 301 and 312), which looks for a `data-testid` attribute. Because of this mismatch, the assertion will always return null, failing to detect actual render errors.
To resolve this, you should update the `RenderErrorBoundary` to use `data-testid` instead of `data-test` to match the testing library's expectation.
Would you like me to implement this fix and check the rest of the comments on this PR?
**superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx**
```
render() {
if (this.state.hasError) {
return <div data-testid="render-error">Render error</div>;
}
return this.props.children;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43150:
URL: https://github.com/apache/superset/pull/43150#discussion_r3943102562
##########
superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx:
##########
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import '@testing-library/jest-dom';
+import { Component, type ReactNode } from 'react';
+import { render, screen } from '@superset-ui/core/spec';
+import { CellProps, Column, HeaderProps } from 'react-table';
+import DataTable from '../../src/DataTable/DataTable';
+import { ProviderWrapper } from '../testHelpers';
+
+type DataRow = {
+ city: string;
+ firstName: string;
+};
+
+interface RenderErrorBoundaryProps {
+ children: ReactNode;
+}
+
+interface RenderErrorBoundaryState {
+ hasError: boolean;
+}
+
+const columns: Column<DataRow>[] = [
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>First name</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'firstName',
+ accessor: 'firstName' as never,
+ },
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>City</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'city',
+ accessor: 'city' as never,
+ },
+];
+
+const data: DataRow[] = [
+ { firstName: 'Michael', city: 'Paris' },
+ { firstName: 'Jordan', city: 'London' },
+];
+
+// Turns a render-phase throw, such as a Rules of Hooks violation, into a
+// readable assertion instead of an unhandled error.
+class RenderErrorBoundary extends Component<
+ RenderErrorBoundaryProps,
+ RenderErrorBoundaryState
+> {
+ state: RenderErrorBoundaryState = {
+ hasError: false,
+ };
+
+ static getDerivedStateFromError() {
+ return { hasError: true };
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return <div data-test="render-error">Render error</div>;
+ }
+
+ return this.props.children;
+ }
+}
+
+const renderDataTable = (tableColumns: Column<DataRow>[]) => (
+ <ProviderWrapper>
+ <RenderErrorBoundary>
+ <DataTable<DataRow>
+ columns={tableColumns}
+ data={data}
+ rowCount={data.length}
+ serverPagination={false}
+ serverPaginationData={{}}
+ onServerPaginationChange={jest.fn()}
+ handleSortByChange={jest.fn()}
+ sortByFromParent={[]}
+ onSearchColChange={jest.fn()}
+ searchOptions={[]}
+ onFilteredRowsChange={jest.fn()}
+ sticky={false}
+ />
+ </RenderErrorBoundary>
+ </ProviderWrapper>
+);
+
+test('keeps the hook order stable when the columns disappear', () => {
+ const { rerender } = render(renderDataTable(columns));
+
+ expect(screen.getByText('Michael')).toBeInTheDocument();
+
+ rerender(renderDataTable([]));
+
+ expect(screen.queryByTestId('render-error')).not.toBeInTheDocument();
Review Comment:
โ
**Customized review instruction saved!**
**Instruction:**
> Respect the test framework's configured testIdAttribute when reviewing test queries; do not flag data-testid/data-test mismatches when the test setup aliases them.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.tsx`
---
๐ก *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #43150:
URL: https://github.com/apache/superset/pull/43150#discussion_r3785872140
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a deterministic
+// concatenation of visible values (keys sorted so column order changes are detected).
+function stableRowKey<D extends object>(r: Row<D>): string {
+ const orig = r.original as Record<string, unknown> | undefined;
+ if (orig) {
+ const idLike =
+ (orig as any).id ??
+ (orig as any).ID ??
+ (orig as any).key ??
+ (orig as any).uuid;
+ if (idLike != null) return String(idLike);
Review Comment:
`stableRowKey` uses several `(orig as any)` casts to probe common id fields. Since `orig` is already a `Record<string, unknown>`, you can read these properties without `any` and keep the function fully type-safe.
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a deterministic
+// concatenation of visible values (keys sorted so column order changes are detected).
Review Comment:
The comment says keys are sorted so column order changes are detected, but sorting keys actually makes the derived key independent of column order. This is misleading for future maintenance; update the wording to reflect that sorting enforces deterministic ordering / stability across column-order changes.
This issue also appears on line 119 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5289914627
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43150?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `97.77778%` with `1 line` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.67%. Comparing base ([`537f0fd`](https://app.codecov.io/gh/apache/superset/commit/537f0fd2dbe19e6d0fbf136c484150e567b0961f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0c31b09`](https://app.codecov.io/gh/apache/superset/commit/0c31b0901f8c1405efdb043348a914adca0181b5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43150?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...ins/plugin-chart-table/src/DataTable/DataTable.tsx](https://app.codecov.io/gh/apache/superset/pull/43150?src=pr&el=tree&filepath=superset-frontend%2Fplugins%2Fplugin-chart-table%2Fsrc%2FDataTable%2FDataTable.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGx1Z2lucy9wbHVnaW4tY2hhcnQtdGFibGUvc3JjL0RhdGFUYWJsZS9EYXRhVGFibGUudHN4) | 97.77% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43150?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #43150 +/- ##
=======================================
Coverage 66.67% 66.67%
=======================================
Files 2871 2871
Lines 163328 163328
Branches 37674 37674
=======================================
+ Hits 108904 108906 +2
+ Misses 52296 52294 -2
Partials 2128 2128
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/43150/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage ฮ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/43150/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.73% <97.77%> (+<0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43150?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #43150:
URL: https://github.com/apache/superset/pull/43150#discussion_r3943101803
##########
superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx:
##########
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import '@testing-library/jest-dom';
+import { Component, type ReactNode } from 'react';
+import { render, screen } from '@superset-ui/core/spec';
+import { CellProps, Column, HeaderProps } from 'react-table';
+import DataTable from '../../src/DataTable/DataTable';
+import { ProviderWrapper } from '../testHelpers';
+
+type DataRow = {
+ city: string;
+ firstName: string;
+};
+
+interface RenderErrorBoundaryProps {
+ children: ReactNode;
+}
+
+interface RenderErrorBoundaryState {
+ hasError: boolean;
+}
+
+const columns: Column<DataRow>[] = [
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>First name</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'firstName',
+ accessor: 'firstName' as never,
+ },
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>City</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'city',
+ accessor: 'city' as never,
+ },
+];
+
+const data: DataRow[] = [
+ { firstName: 'Michael', city: 'Paris' },
+ { firstName: 'Jordan', city: 'London' },
+];
+
+// Turns a render-phase throw, such as a Rules of Hooks violation, into a
+// readable assertion instead of an unhandled error.
+class RenderErrorBoundary extends Component<
+ RenderErrorBoundaryProps,
+ RenderErrorBoundaryState
+> {
+ state: RenderErrorBoundaryState = {
+ hasError: false,
+ };
+
+ static getDerivedStateFromError() {
+ return { hasError: true };
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return <div data-test="render-error">Render error</div>;
+ }
+
+ return this.props.children;
+ }
+}
+
+const renderDataTable = (tableColumns: Column<DataRow>[]) => (
+ <ProviderWrapper>
+ <RenderErrorBoundary>
+ <DataTable<DataRow>
+ columns={tableColumns}
+ data={data}
+ rowCount={data.length}
+ serverPagination={false}
+ serverPaginationData={{}}
+ onServerPaginationChange={jest.fn()}
+ handleSortByChange={jest.fn()}
+ sortByFromParent={[]}
+ onSearchColChange={jest.fn()}
+ searchOptions={[]}
+ onFilteredRowsChange={jest.fn()}
+ sticky={false}
+ />
+ </RenderErrorBoundary>
+ </ProviderWrapper>
+);
+
+test('keeps the hook order stable when the columns disappear', () => {
+ const { rerender } = render(renderDataTable(columns));
+
+ expect(screen.getByText('Michael')).toBeInTheDocument();
+
+ rerender(renderDataTable([]));
+
+ expect(screen.queryByTestId('render-error')).not.toBeInTheDocument();
Review Comment:
I think this one's a false positive. `spec/helpers/setup.ts` sets `testIdAttribute: 'data-test'` for the whole jest suite, so `queryByTestId('render-error')` does find that `data-test` node. Resolving.
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a deterministic
+// concatenation of visible values (keys sorted so column order changes are detected).
Review Comment:
Looks like the comment wording got fixed up in the follow-up commit, it now says sorting makes the key independent of column order. Resolving.
##########
superset-frontend/plugins/plugin-chart-table/src/DataTable/DataTable.tsx:
##########
@@ -103,6 +103,44 @@ const sortTypes = {
alphanumeric: sortAlphanumericCaseInsensitive,
};
+// Prefer a stable identifier from original row data; otherwise use a deterministic
+// concatenation of visible values (keys sorted so column order changes are detected).
+function stableRowKey<D extends object>(r: Row<D>): string {
+ const orig = r.original as Record<string, unknown> | undefined;
+ if (orig) {
+ const idLike =
+ (orig as any).id ??
+ (orig as any).ID ??
+ (orig as any).key ??
+ (orig as any).uuid;
+ if (idLike != null) return String(idLike);
Review Comment:
The `as any` casts are gone in the latest push, `orig` is read straight off the `Record<string, unknown>` now. Resolving.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5298415413
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #43150:
URL: https://github.com/apache/superset/pull/43150
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43150:
URL: https://github.com/apache/superset/pull/43150#discussion_r3781275178
##########
superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx:
##########
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import '@testing-library/jest-dom';
+import { Component, type ReactNode } from 'react';
+import { render, screen } from '@superset-ui/core/spec';
+import { CellProps, Column, HeaderProps } from 'react-table';
+import DataTable from '../../src/DataTable/DataTable';
+import { ProviderWrapper } from '../testHelpers';
+
+type DataRow = {
+ city: string;
+ firstName: string;
+};
+
+interface RenderErrorBoundaryProps {
+ children: ReactNode;
+}
+
+interface RenderErrorBoundaryState {
+ hasError: boolean;
+}
+
+const columns: Column<DataRow>[] = [
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>First name</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'firstName',
+ accessor: 'firstName' as never,
+ },
+ {
+ Header: ({ column }: HeaderProps<DataRow>) => (
+ <th data-column-name={column.id}>City</th>
+ ),
+ Cell: ({ value }: CellProps<DataRow>) => <td>{value}</td>,
+ id: 'city',
+ accessor: 'city' as never,
+ },
+];
+
+const data: DataRow[] = [
+ { firstName: 'Michael', city: 'Paris' },
+ { firstName: 'Jordan', city: 'London' },
+];
+
+// Turns a render-phase throw, such as a Rules of Hooks violation, into a
+// readable assertion instead of an unhandled error.
+class RenderErrorBoundary extends Component<
+ RenderErrorBoundaryProps,
+ RenderErrorBoundaryState
+> {
+ state: RenderErrorBoundaryState = {
+ hasError: false,
+ };
+
+ static getDerivedStateFromError() {
+ return { hasError: true };
+ }
+
+ render() {
+ if (this.state.hasError) {
+ return <div data-test="render-error">Render error</div>;
+ }
+
+ return this.props.children;
+ }
+}
+
+const renderDataTable = (tableColumns: Column<DataRow>[]) => (
+ <ProviderWrapper>
+ <RenderErrorBoundary>
+ <DataTable<DataRow>
+ columns={tableColumns}
+ data={data}
+ rowCount={data.length}
+ serverPagination={false}
+ serverPaginationData={{}}
+ onServerPaginationChange={jest.fn()}
+ handleSortByChange={jest.fn()}
+ sortByFromParent={[]}
+ onSearchColChange={jest.fn()}
+ searchOptions={[]}
+ onFilteredRowsChange={jest.fn()}
+ sticky={false}
+ />
+ </RenderErrorBoundary>
+ </ProviderWrapper>
+);
+
+test('keeps the hook order stable when the columns disappear', () => {
+ const { rerender } = render(renderDataTable(columns));
+
+ expect(screen.getByText('Michael')).toBeInTheDocument();
+
+ rerender(renderDataTable([]));
+
+ expect(screen.queryByTestId('render-error')).not.toBeInTheDocument();
Review Comment:
**Suggestion:** The error boundary renders `data-test="render-error"`, but this assertion queries for `data-testid="render-error"`. Consequently, it always returns null even when the boundary catches a render error, so the regression tests can pass while the DataTable is still broken. Use the same attribute in the boundary and assertion. [api mismatch]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Both hook-order regression tests contain ineffective error-boundary assertions.
- โ ๏ธ Future render failures can be misdiagnosed by these tests.
- โ ๏ธ The reverse transition repeats the same attribute mismatch.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f079a4577c404ac2a8fb73e44515390b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f079a4577c404ac2a8fb73e44515390b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-table/test/DataTable/DataTable.test.tsx
**Line:** 114:114
**Comment:**
*Api Mismatch: The error boundary renders `data-test="render-error"`, but this assertion queries for `data-testid="render-error"`. Consequently, it always returns null even when the boundary catches a render error, so the regression tests can pass while the DataTable is still broken. Use the same attribute in the boundary and assertion.
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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43150&comment_hash=0fa096465a7e24583c24370876fec50295743a7cb8dae3c87a316902ff6f4dbe&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43150&comment_hash=0fa096465a7e24583c24370876fec50295743a7cb8dae3c87a316902ff6f4dbe&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5289720241
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(plugin-chart-table): declare DataTable hooks before the early return [superset]
Posted by "NoiceHax (via GitHub)" <gi...@apache.org>.
NoiceHax commented on PR #43150:
URL: https://github.com/apache/superset/pull/43150#issuecomment-5296850417
Pushed a follow-up for the review comments.
On the data-test vs data-testid flag from the bots: that one is a false positive. spec/helpers/setup.ts calls configureTestingLibrary({ testIdAttribute: 'data-test' }), so queryByTestId('render-error') already resolves the data-test node. I left the query as is and added a short comment pointing at the setup file so it does not get flagged again.
Took the two Copilot points. Dropped the (orig as any) casts, orig is already Record<string, unknown> so the id probes type check without them, and reworded the comments that said sorting the keys detects column order changes. Sorting does the opposite, it makes the key independent of column order.
One extra bit of evidence for the fix itself. Running oxlint on the file as it was before this PR reports five react-hooks/rules-of-hooks 'called conditionally' warnings, which are exactly the five hooks this PR moves above the early return. After the change all five are gone and only the pre-existing exhaustive-deps warning is left.
I still could not run jest locally (no node_modules in this environment), so the new tests are only covered by CI, which is green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org