codeant-ai-for-open-source[bot] commented on code in PR #37531:
URL: https://github.com/apache/superset/pull/37531#discussion_r2834669384
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:
##########
@@ -349,17 +372,19 @@ export function transformSeries(
return {
...series,
- ...(Array.isArray(data) && seriesType === 'bar'
- ? {
- data: optimizeBarLabelPlacement(series, isHorizontal),
- }
+ ...(Array.isArray(data)
+ ? colorByPrimaryAxis
+ ? { data: applyColorByXAxis(series, colorScale, sliceId, opacity) }
+ : seriesType === 'bar' && !stack
+ ? { data: optimizeBarLabelPlacement(series, isHorizontal) }
+ : null
: null),
Review Comment:
**Suggestion:** The conditional spread in the returned series object uses
`null` as the "no-op" branch, which leads to `...null` in an object literal
when `colorByPrimaryAxis` is false or `seriesType` is not `'bar'`; this throws
a runtime "Cannot convert undefined or null to object" error for most charts
(e.g., line/area) where `data` is an array. [type error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Timeseries ECharts charts crash when transforming non-bar series.
- ❌ Line and area timeseries become unusable at render time.
- ⚠️ New color-by-primary-axis flag unsafe to enable broadly.
```
</details>
```suggestion
: {}
: {}),
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:205-273`,
call `transformSeries` with a `series` object whose `data` is an array of
`[x, y]` points
(standard ECharts series data) and `opts` such that `colorByPrimaryAxis` is
`false`,
`seriesType` is `'line'`, and `stack` is `undefined`.
2. Inside `transformSeries`, execution reaches the return statement at
`transformers.ts:373-454`, where `data` is the array passed in step 1, so
`Array.isArray(data)` evaluates to `true`.
3. Because `colorByPrimaryAxis` is `false` and `seriesType === 'bar' &&
!stack` is `false`
for a `'line'` series, the nested conditional expression `colorByPrimaryAxis
? ... :
seriesType === 'bar' && !stack ? ... : null` (lines `376-380`) evaluates to
`null`.
4. The object spread `...(Array.isArray(data) ? ... : null)` at
`transformers.ts:375-381`
becomes `...null`, which at runtime throws `TypeError: Cannot convert
undefined or null to
object`, preventing the transformed series from being created for any
non-bar timeseries
that passes array data.
```
</details>
<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/Timeseries/transformers.ts
**Line:** 380:381
**Comment:**
*Type Error: The conditional spread in the returned series object uses
`null` as the "no-op" branch, which leads to `...null` in an object literal
when `colorByPrimaryAxis` is false or `seriesType` is not `'bar'`; this throws
a runtime "Cannot convert undefined or null to object" error for most charts
(e.g., line/area) where `data` is an array.
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%2F37531&comment_hash=252d001fcd9a1488dab90cac43871d3fe47b655d0a6a6a353670cfbf5e139033&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37531&comment_hash=252d001fcd9a1488dab90cac43871d3fe47b655d0a6a6a353670cfbf5e139033&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]