codeant-ai-for-open-source[bot] commented on code in PR #38458:
URL: https://github.com/apache/superset/pull/38458#discussion_r2943739447
##########
superset-frontend/plugins/legacy-plugin-chart-map-box/src/ScatterPlotGlowOverlay.tsx:
##########
@@ -187,7 +191,10 @@ class ScatterPlotGlowOverlay extends
PureComponent<ScatterPlotGlowOverlayProps>
// Guard against empty array or zero max to prevent NaN from division
const maxLabel =
filteredLabels.length > 0 ? Math.max(...filteredLabels) : 1;
- const safeMaxLabel = maxLabel > 0 ? maxLabel : 1;
+ const minLabel =
+ filteredLabels.length > 0 ? Math.min(...filteredLabels) : 0;
+ const maxAbsLabel = Math.max(Math.abs(maxLabel), Math.abs(minLabel));
+ const safeMaxAbsLabel = maxAbsLabel > 0 ? maxAbsLabel : 1;
Review Comment:
**Suggestion:** The new absolute-label normalization can break when cluster
labels are non-finite/non-numeric values, because `minLabel`/`maxLabel` can
become invalid and then `safeMaxAbsLabel` no longer reflects real label
magnitude. That can collapse cluster sizes to the floor or inflate them beyond
expected bounds. Compute `safeMaxAbsLabel` from finite numeric labels only.
[logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Cluster bubble sizing breaks with non-numeric aggregate labels.
- ⚠️ Legacy MapBox overlay can render invalid cluster circles.
```
</details>
```suggestion
const numericLabels = filteredLabels
.map(value => Number(value))
.filter(value => Number.isFinite(value));
const safeMaxAbsLabel =
numericLabels.length > 0
? Math.max(...numericLabels.map(value => Math.abs(value)))
: 1;
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Configure MapBox with a non-numeric `mapbox_label` column (documented as
allowed for
labels in `src/controlPanel.ts:155-158`) and keep clustering enabled.
2. Backend sets `has_custom_metric` true and forwards that label column as
`metric` values
in GeoJSON (`superset/viz.py:1457-1466,1482`), including strings.
3. Frontend `transformProps` enables custom Supercluster reducers when
`hasCustomMetric`
is true (`src/transformProps.ts:62-77`), so cluster aggregate fields can
become
non-numeric strings.
4. During redraw, `filteredLabels` accepts non-NaN non-numeric entries
(`src/ScatterPlotGlowOverlay.tsx:188-190`), `Math.max/Math.min` can become
`NaN`
(`:192-197`), then `scaledRadius` uses invalid divisor (`:253-255`), causing
broken
cluster sizing/rendering.
```
</details>
<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-map-box/src/ScatterPlotGlowOverlay.tsx
**Line:** 192:197
**Comment:**
*Logic Error: The new absolute-label normalization can break when
cluster labels are non-finite/non-numeric values, because `minLabel`/`maxLabel`
can become invalid and then `safeMaxAbsLabel` no longer reflects real label
magnitude. That can collapse cluster sizes to the floor or inflate them beyond
expected bounds. Compute `safeMaxAbsLabel` from finite numeric labels only.
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.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38458&comment_hash=751e188703e3e7482edffc9f5bd8ed6d234ce03fa732fb2d2ac8f9b5fcb4e7b6&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38458&comment_hash=751e188703e3e7482edffc9f5bd8ed6d234ce03fa732fb2d2ac8f9b5fcb4e7b6&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]