codeant-ai-for-open-source[bot] commented on code in PR #41678:
URL: https://github.com/apache/superset/pull/41678#discussion_r3511257418
##########
superset-frontend/src/components/Chart/useDrillDetailMenuItems/index.tsx:
##########
@@ -219,33 +220,41 @@ export const useDrillDetailMenuItems = ({
popupOffset: [0, submenuYOffset],
popupClassName: 'chart-context-submenu',
children: [
- ...filters.map((filter, i) => ({
- key: `drill-detail-filter-${i}`,
- onClick: openModal.bind(null, [filter]),
- label: (
- <div
- css={css`
- max-width: 200px;
- `}
- >
- <TruncatedMenuLabel
- tooltipText={`${DRILL_TO_DETAIL_BY}
${filter.formattedVal}`}
- aria-label={`${DRILL_TO_DETAIL_BY} ${filter.formattedVal}`}
+ ...filters.map((filter, i) => {
+ const isNullVal =
+ isEmpty(filter.formattedVal) ||
+ filter.formattedVal === NULL_STRING;
+ const formattedVal = isNullVal
+ ? NULL_STRING
+ : filter.formattedVal;
Review Comment:
**Suggestion:** The null-detection logic treats any empty `formattedVal` as
null and rewrites it to `<NULL>`, which incorrectly relabels real empty-string
dimension values as null. This breaks value semantics (empty string vs null)
and produces wrong drill labels. Restrict null handling to actual null markers
(`filter.val == null` and/or `formattedVal === NULL_STRING`) and keep empty
strings mapped to their proper empty-string representation instead of
`NULL_STRING`. [incorrect condition logic]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ ChartContextMenu drill labels misrepresent empty string dimensions.
- ⚠️ DrillDetailModal filter summary mislabels empty-string values.
- ⚠️ Conflicts with EMPTY_STRING semantics in src/utils/common.ts.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure a chart that uses the shared ECharts context menu handler
(`contextMenuEventHandler` in
`plugins/plugin-chart-echarts/src/utils/eventHandlers.ts`,
lines 130-22) with a `groupby` dimension whose actual data value is the
empty string ''
(not null). This handler builds `drillFilters` with `val: values[i]` and
`formattedVal:
formatSeriesName(values[i], ...)` (eventHandlers.ts:4-14).
2. Right-click on a data point whose groupby dimension is the empty string.
In
`formatSeriesName` (`plugins/plugin-chart-echarts/src/utils/series.ts`,
lines 181-213),
the function returns `name` unchanged when `name` is a string, so for an
empty string it
returns `''`. The resulting `BinaryQueryObjectFilterClause` in
`drillFilters` has `val:
''` and `formattedVal: ''`.
3. The chart’s `onContextMenu` propagates these filters into the dashboard
context menu
via `useContextMenu`
(`src/components/Chart/ChartContextMenu/useContextMenu.tsx`, lines
39-45), which calls `ChartContextMenuRef.open`. `ChartContextMenu.open`
(`src/components/Chart/ChartContextMenu/ChartContextMenu.tsx`, lines
125-141) stores the
filters and then renders the menu; it passes `filters?.drillToDetail` into
`useDrillDetailMenuItems` (`ChartContextMenu.tsx`, lines 9-21), so the hook
receives the
filter with `formattedVal === ''`.
4. Inside `useDrillDetailMenuItems`
(`superset-frontend/src/components/Chart/useDrillDetailMenuItems/index.tsx`,
lines 44-50
in the PR), the hook computes `isNullVal = isEmpty(filter.formattedVal) ||
filter.formattedVal === NULL_STRING` and then `formattedVal = isNullVal ?
NULL_STRING :
filter.formattedVal`. For the empty-string case, `isEmpty('')` is true, so
`isNullVal` is
true and `formattedVal` is rewritten to `NULL_STRING`. The drill-to-detail
submenu label
and tooltip (`index.tsx`, lines 60-72) therefore render `Drill to detail by
<NULL>` while
the underlying filter `val` is still `''`, misrepresenting a real
empty-string dimension
value as null and contradicting the established empty-string handling in
`src/utils/common.ts` where empty strings map to `EMPTY_STRING` (<empty
string>).
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e5157441248844ab8f715b074dce1955&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=e5157441248844ab8f715b074dce1955&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/useDrillDetailMenuItems/index.tsx
**Line:** 224:229
**Comment:**
*Incorrect Condition Logic: The null-detection logic treats any empty
`formattedVal` as null and rewrites it to `<NULL>`, which incorrectly relabels
real empty-string dimension values as null. This breaks value semantics (empty
string vs null) and produces wrong drill labels. Restrict null handling to
actual null markers (`filter.val == null` and/or `formattedVal ===
NULL_STRING`) and keep empty strings mapped to their proper empty-string
representation instead of `NULL_STRING`.
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%2F41678&comment_hash=79ee363ccebfd1f3b7759063af523b258a7d776f2e30c0c6a632fee4e035a8da&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41678&comment_hash=79ee363ccebfd1f3b7759063af523b258a7d776f2e30c0c6a632fee4e035a8da&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]