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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Sankey/transformProps.ts:
##########
@@ -105,25 +180,51 @@ export default function transformProps(
     const { source, target } = data as Link;
     if (source && target) {
       rows.push([
-        `% (${source})`,
+        `% (${displayName(source)})`,
         percentFormatter.format(value / nodeValues.get(source)!),
       ]);
       rows.push([
-        `% (${target})`,
+        `% (${displayName(target)})`,
         percentFormatter.format(value / nodeValues.get(target)!),

Review Comment:
   **Suggestion:** Link tooltips divide by `nodeValues` without handling a zero 
denominator. A valid zero-valued metric result produces a node total of zero, 
so these divisions yield `NaN` or `Infinity` and the tooltip displays an 
invalid percentage. Guard zero totals and render an appropriate value instead. 
[logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Sankey link tooltips show invalid percentages for zero-valued flows.
   - ⚠️ Zero-valued aggregate metrics produce `NaN` tooltip output.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a Sankey chart through the registered plugin in
   `superset-frontend/plugins/plugin-chart-echarts/src/Sankey/index.ts:34-72` 
with a metric
   that can legitimately aggregate to zero, such as a sum containing offsetting 
positive and
   negative values.
   
   2. The Sankey query builder at
   
`superset-frontend/plugins/plugin-chart-echarts/src/Sankey/buildQuery.ts:26-55` 
returns
   grouped rows without filtering zero metric results, so a row with `count` or 
the selected
   metric equal to `0` reaches `transformProps`.
   
   3. `transformProps` at
   
`superset-frontend/plugins/plugin-chart-echarts/src/Sankey/transformProps.ts:105-129`
   creates a link with `value: 0`; the flow totals at lines 156-174 then set 
both endpoint
   node values to `0`.
   
   4. Hover the zero-valued link so the tooltip formatter at
   
`superset-frontend/plugins/plugin-chart-echarts/src/Sankey/transformProps.ts:176-196`
   executes. Lines 184 and 188 evaluate `0 / 0`, passing `NaN` to 
`percentFormatter` and
   rendering an invalid percentage instead of a meaningful zero or unavailable 
value.
   ```
   </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=3eb0ab406153462f84a81ad54ed80c2f&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=3eb0ab406153462f84a81ad54ed80c2f&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/Sankey/transformProps.ts
   **Line:** 182:188
   **Comment:**
        *Logic Error: Link tooltips divide by `nodeValues` without handling a 
zero denominator. A valid zero-valued metric result produces a node total of 
zero, so these divisions yield `NaN` or `Infinity` and the tooltip displays an 
invalid percentage. Guard zero totals and render an appropriate value instead.
   
   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%2F42477&comment_hash=ac059cd4a07e092fdeaa5f36e603839da1ecf5c36366891c2401d90b5987806a&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42477&comment_hash=ac059cd4a07e092fdeaa5f36e603839da1ecf5c36366891c2401d90b5987806a&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