korbit-ai[bot] commented on code in PR #34250:
URL: https://github.com/apache/superset/pull/34250#discussion_r2280922371
##########
superset-frontend/plugins/plugin-chart-echarts/src/Waterfall/controlPanel.tsx:
##########
@@ -160,6 +161,19 @@ const config: ControlPanelConfig = {
multi: false,
},
},
+ formDataOverrides: formData => {
+ const controls = getStandardizedControls();
+
+ // Keep the 0th element and discard the rest, and modify the original
instance array directly
+ if (controls.controls.metrics.length > 1) {
+ controls.controls.metrics = [controls.controls.metrics[0]];
+ }
Review Comment:
### Missing null check on metrics array <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The code directly modifies the controls.controls.metrics array without
verifying if it exists or if it's an array.
###### Why this matters
If controls.controls.metrics is undefined or not an array, this will cause a
runtime error and crash the application when switching chart types.
###### Suggested change ∙ *Feature Preview*
Add null checks and type verification before accessing the metrics array:
```typescript
if (controls.controls?.metrics && Array.isArray(controls.controls.metrics)
&& controls.controls.metrics.length > 1) {
controls.controls.metrics = [controls.controls.metrics[0]];
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/04881152-d686-41e7-88e8-a1838cca22f0/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/04881152-d686-41e7-88e8-a1838cca22f0?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/04881152-d686-41e7-88e8-a1838cca22f0?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/04881152-d686-41e7-88e8-a1838cca22f0?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/04881152-d686-41e7-88e8-a1838cca22f0)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:4f2cd2ae-0295-4063-ae79-395875c5242e -->
[](4f2cd2ae-0295-4063-ae79-395875c5242e)
--
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]