codeant-ai-for-open-source[bot] commented on code in PR #37229:
URL: https://github.com/apache/superset/pull/37229#discussion_r2716949765
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -146,6 +147,8 @@ export default function transformProps(
detected_currency: backendDetectedCurrency,
} = queryData as TimeseriesChartDataResponseResult;
Review Comment:
**Suggestion:** Logic bug: the datasource property is destructured as
`verboseMap` (camelCase) but the backend/protobuf payload uses `verbose_map`
(snake_case) in other places; as written, when the datasource provides
`verbose_map` the code will ignore it and `originalVerboseMap` will default to
{}, losing the original verbose mapping. Use both keys (or prefer
`verbose_map`) so existing verbose labels are preserved. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Timeseries tooltip labels show raw metric keys
- ❌ Forecast series tooltip human-readable labels missing
- ⚠️ Chart legend may display raw column names
```
</details>
```suggestion
// support both snake_case (backend) and camelCase (possible consumers)
verbose_map: originalVerboseMapSnake = {},
verboseMap: originalVerboseMapCamel = {},
columnFormats = {},
currencyFormats = {},
currencyCodeColumn,
} = datasource;
const [queryData] = queriesData;
const {
data = [],
label_map = {},
detected_currency: backendDetectedCurrency,
} = queryData as TimeseriesChartDataResponseResult;
// prefer snake_case payload if present, otherwise fall back to camelCase
const originalVerboseMap =
Object.keys(originalVerboseMapSnake).length > 0
? originalVerboseMapSnake
: originalVerboseMapCamel;
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the Timeseries chart rendering path which calls transformProps in
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
(function declaration at transformProps.ts:117). This function receives
chartProps including `datasource`.
2. Observe datasource destructuring at transformProps.ts:138-142 where the
code
only looks for the camelCase `verboseMap` property:
"const { verboseMap: originalVerboseMap = {}, ... } = datasource;".
3. In a real backend response the human-readable mapping is provided as
snake_case `verbose_map`. When datasource only contains `verbose_map`
(and not `verboseMap`), originalVerboseMap defaults to {} at
transformProps.ts:138-142.
4. At transformProps.ts:150 the code calls
"const verboseMap = addLabelMapToVerboseMap(label_map,
originalVerboseMap);"
passing the now-empty originalVerboseMap. Because the backend-provided
`verbose_map` was ignored, the combined verboseMap lacks expected
human-readable entries and tooltip/label resolution falls back to raw
keys.
```
</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/transformProps.ts
**Line:** 139:149
**Comment:**
*Logic Error: Logic bug: the datasource property is destructured as
`verboseMap` (camelCase) but the backend/protobuf payload uses `verbose_map`
(snake_case) in other places; as written, when the datasource provides
`verbose_map` the code will ignore it and `originalVerboseMap` will default to
{}, losing the original verbose mapping. Use both keys (or prefer
`verbose_map`) so existing verbose labels are preserved.
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>
--
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]