codeant-ai-for-open-source[bot] commented on code in PR #26230:
URL: https://github.com/apache/superset/pull/26230#discussion_r3615970473
##########
superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.ts:
##########
@@ -98,10 +102,14 @@ function Calendar(element: HTMLElement, props:
CalendarProps) {
calContainer.text(`${METRIC_TEXT}: ${verboseMap[metric] || metric}`);
}
const timestamps = metricsData[metric];
- const rawExtents = d3Extent(
- Object.keys(timestamps),
- key => timestamps[key],
- );
+ const useCustomColorRange =
+ Number.isFinite(colorRangeStart) && Number.isFinite(colorRangeEnd);
Review Comment:
**Suggestion:** The custom range gate uses `Number.isFinite` directly on
form values, but `TextControl` commonly provides string values (for example
`"1"`), so the check returns false and the custom color range is silently
ignored even when users entered valid numbers. Coerce the inputs to numbers
first, then validate finiteness on the coerced values before deciding whether
to use custom extents. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Custom color range inputs ignored; chart uses auto scaling.
- ⚠️ Users cannot control calendar heatmap color domain.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the Calendar Heatmap visualization in Explore so that the legacy
plugin at
`superset-frontend/plugins/legacy-plugin-chart-calendar/src/Calendar.ts` is
used to render
the chart.
2. In the Chart Options panel, set the new "Color Range Start" and "Color
Range End"
controls (wired through the plugin's control panel and transformProps) to
numeric strings
such as `"1"` and `"10"`, which are stored in `formData` as strings.
3. The plugin's `transformProps` function (in the calendar heatmap plugin
directory)
passes these raw form values directly into the `Calendar` component's
`colorRangeStart`
and `colorRangeEnd` props without numeric coercion, so inside
`Calendar(element, props)`
at lines 63–83 they arrive as strings.
4. When rendering each metric, `Calendar` executes the logic at lines
105–106:
`Number.isFinite(colorRangeStart) && Number.isFinite(colorRangeEnd)` returns
`false` for
string inputs, `useCustomColorRange` remains `false`, and the chart falls
back to
automatic `d3Extent(...)` scaling, ignoring the user-specified color range
even though the
values are valid numbers.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=64a1aecc75774c21ace21218684d2360&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=64a1aecc75774c21ace21218684d2360&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/legacy-plugin-chart-calendar/src/Calendar.ts
**Line:** 105:106
**Comment:**
*Logic Error: The custom range gate uses `Number.isFinite` directly on
form values, but `TextControl` commonly provides string values (for example
`"1"`), so the check returns false and the custom color range is silently
ignored even when users entered valid numbers. Coerce the inputs to numbers
first, then validate finiteness on the coerced values before deciding whether
to use custom extents.
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%2F26230&comment_hash=a011d4d623585c1620261d47d73d1e9698bc87b7efe2e4a843a0c601863b3f1f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F26230&comment_hash=a011d4d623585c1620261d47d73d1e9698bc87b7efe2e4a843a0c601863b3f1f&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]