codeant-ai-for-open-source[bot] commented on code in PR #37396:
URL: https://github.com/apache/superset/pull/37396#discussion_r3481296223
##########
superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx:
##########
@@ -47,6 +47,7 @@ export const useResultsTableView = (
<ResultContainer data-test="drill-by-results-table">
<SingleQueryResultPane
colnames={chartDataResult[0].colnames}
+ collabels={chartDataResult[0].collabels}
coltypes={chartDataResult[0].coltypes}
Review Comment:
**Suggestion:** `collabels` is forwarded directly without normalization, but
downstream grid logic assumes label arrays align with `colnames`; when labels
are missing/short (common with legacy or partial responses), headers/menu
labels can become undefined instead of reliably falling back to column names.
Normalize before passing (for example, derive a full labels array from
`colnames` when absent) to preserve stable header rendering. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Drill-by results table may show missing column headers.
- ⚠️ Legacy API drill-by uses unnormalized column label metadata.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure or use a visualization whose metadata sets `useLegacyApi` to
true (legacy
path supported by `getQuerySettings()` in
`superset-frontend/src/explore/exploreUtils/index.ts:40-49`, which returns
`[vizMetadata?.useLegacyApi ?? false, parseMethod]`).
2. Open the Drill By modal for that chart so `DrillByModal` in
`superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx:169-176`
builds
`drilledFormData` and calls `getChartDataRequest({ formData: drilledFormData
})` at
`chartAction.ts:145-151`; with `useLegacyApi` true, `getChartDataRequest()`
delegates to
`legacyChartDataRequest()` (`chartAction.ts:408-444`) which hits
`/superset/explore_json/`
and wraps its raw JSON as `{ result: [json] }`.
3. Because the legacy `/superset/explore_json/` path is not wired to
`extract_display_labels()` and never sets `collabels` (verified via `grep
'collabels'`
only finding definitions in `superset/common/query_actions.py:168-201` and
`superset/charts/schemas.py:1618-1621`), the `QueryData` objects for this
Drill By request
arrive in `DrillByModal` without a `collabels` field.
4. `DrillByModal` stores this array in `chartDataResult` (state set in
`handleReload` and
the `useEffect` at `DrillByModal.tsx:142-161` and `233-246`) and passes it
into
`useResultsTableView()` (`useResultsTableView.tsx:34-41`), which forwards
`collabels={chartDataResult[0].collabels}` at
`useResultsTableView.tsx:48-51` to
`SingleQueryResultPane`; inside `SingleQueryResultPane`
(`SingleQueryResultPane.tsx:49-67`), `useGridColumns(colnames, coltypes,
collabels, data)`
is called, and `useGridColumns` computes `headerLabel =
collabels?.[originalIndex]` and
`headerName: headerLabel` (`useGridResultTable.tsx:45-52`). With `collabels`
undefined in
the legacy case, `headerName` becomes undefined, so GridTable
(`GridTable/index.tsx:104-120`) renders column definitions with `headerName`
unset and no
explicit fallback to `colnames`, leading to headers that may render blank or
inconsistent
instead of reliably matching the column names.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=044cb4e2fb914572b67cb47dd54ea694&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=044cb4e2fb914572b67cb47dd54ea694&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/components/Chart/DrillBy/useResultsTableView.tsx
**Line:** 51:51
**Comment:**
*Logic Error: `collabels` is forwarded directly without normalization,
but downstream grid logic assumes label arrays align with `colnames`; when
labels are missing/short (common with legacy or partial responses),
headers/menu labels can become undefined instead of reliably falling back to
column names. Normalize before passing (for example, derive a full labels array
from `colnames` when absent) to preserve stable header rendering.
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%2F37396&comment_hash=39c43531313b702f3eb12e52c6c1edf08451fb8258701d2d4d1b6f1f535cfc82&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37396&comment_hash=39c43531313b702f3eb12e52c6c1edf08451fb8258701d2d4d1b6f1f535cfc82&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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]