codeant-ai-for-open-source[bot] commented on code in PR #37229:
URL: https://github.com/apache/superset/pull/37229#discussion_r3454558700


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -150,6 +151,13 @@ export default function transformProps(
     queriesData[0] as TimeseriesChartDataResponseResult;
   const { label_map: labelMapB, detected_currency: backendDetectedCurrencyB } =
     queriesData[1] as TimeseriesChartDataResponseResult;
+
+  const verboseMapWithLabelMap = addLabelMapToVerboseMap(
+    labelMap,
+    originalVerboseMap,
+  );
+  const verboseMap = addLabelMapToVerboseMap(labelMapB, 
verboseMapWithLabelMap);

Review Comment:
   **Suggestion:** `label_map` is optional in chart responses, but this new 
path passes `labelMap`/`labelMapB` directly into `addLabelMapToVerboseMap`. 
When either query omits `label_map`, `addLabelMapToVerboseMap` will execute 
`Object.entries` on `undefined` and crash render-time tooltip/series 
transformation. Default both inputs to `{}` before calling the helper. [null 
pointer]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Mixed Chart visualization crashes when label_map is omitted.
   - ❌ Dashboards with MixedTimeseries fail to render affected charts.
   - ⚠️ Tooltip and series formatting entirely unavailable on error.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Register and use the Mixed Chart visualization, which is wired up via
   `EchartsTimeseriesChartPlugin` in
   
`superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/index.ts:34-86`,
   pointing its `transformProps` to `./transformProps`.
   
   2. When a Mixed Chart is rendered, `transformProps` in
   
`superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:6-21`
   is invoked with `queriesData` coming from `/api/v1/chart/data` as
   `TimeseriesChartDataResponseResult` objects (`import` at line 40).
   
   3. In `transformProps`, the first two query results are destructured without 
defaults at
   lines 31-34: `const { label_map: labelMap, ... } = queriesData[0] as
   TimeseriesChartDataResponseResult; const { label_map: labelMapB, ... } = 
queriesData[1] as
   TimeseriesChartDataResponseResult;`. If either response omits `label_map`, 
then `labelMap`
   or `labelMapB` becomes `undefined`. The fact that other code (e.g.
   `Timeseries/transformProps.ts:3-16`) destructures `label_map = {}` 
demonstrates the
   frontend expects `label_map` to be absent sometimes.
   
   4. Immediately after, at `MixedTimeseries/transformProps.ts:36-40` (hunk 
lines 155-159),
   `addLabelMapToVerboseMap(labelMap, originalVerboseMap)` and
   `addLabelMapToVerboseMap(labelMapB, verboseMapWithLabelMap)` are called. 
Inside
   `addLabelMapToVerboseMap`
   
(`superset-frontend/plugins/plugin-chart-echarts/src/utils/forecast.ts:90-93,130-132`),
   the helper executes `Object.entries(label_map)` with no null-check. When 
`labelMap` or
   `labelMapB` is `undefined`, this call throws a TypeError (`Cannot convert 
undefined or
   null to object`), causing the Mixed Chart render/tooltip transformation to 
crash and the
   visualization to fail to display.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7b81fe2f85534e81bc8ff2ef7ae17f74&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7b81fe2f85534e81bc8ff2ef7ae17f74&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/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
   **Line:** 155:159
   **Comment:**
        *Null Pointer: `label_map` is optional in chart responses, but this new 
path passes `labelMap`/`labelMapB` directly into `addLabelMapToVerboseMap`. 
When either query omits `label_map`, `addLabelMapToVerboseMap` will execute 
`Object.entries` on `undefined` and crash render-time tooltip/series 
transformation. Default both inputs to `{}` before calling the helper.
   
   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%2F37229&comment_hash=90a4dfd22a7bfe31bd1c2ec874deab989be820f37954d78edd984bcdb36c119f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37229&comment_hash=90a4dfd22a7bfe31bd1c2ec874deab989be820f37954d78edd984bcdb36c119f&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]

Reply via email to