korbit-ai[bot] commented on code in PR #34315:
URL: https://github.com/apache/superset/pull/34315#discussion_r2231167035
##########
superset-frontend/src/pages/ChartList/index.tsx:
##########
@@ -387,7 +387,10 @@ function ChartList(props: ChartListProps) {
},
}: any) => (
<Tooltip title={dsNameTxt} placement="top">
- <GenericLink to={dsUrl}>{dsNameTxt?.split('.')[1]}</GenericLink>
+ {/* dsNameTxt can be undefined, schema.name or just name */}
+ <GenericLink to={dsUrl}>
+ {dsNameTxt ? dsNameTxt.split('.')[1] || dsNameTxt : ''}
Review Comment:
### Unsafe Array Access After Split <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The code attempts to split and access index 1 of the split array without
first checking if the split operation returns an array with at least 2 elements.
###### Why this matters
If dsNameTxt contains no dots, split('.') will return an array with only one
element, making index 1 undefined. The current code will then fall back to
dsNameTxt, which is not the intended behavior as per the developer's intent to
show the name part after the dot.
###### Suggested change ∙ *Feature Preview*
Add a check for the split array length to ensure proper fallback behavior:
```typescript
{
const parts = dsNameTxt?.split('.');
parts?.length > 1 ? parts[1] : dsNameTxt || ''
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4ff6f664-1f28-45d5-bd73-1ace21709cec/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4ff6f664-1f28-45d5-bd73-1ace21709cec?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4ff6f664-1f28-45d5-bd73-1ace21709cec?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4ff6f664-1f28-45d5-bd73-1ace21709cec?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4ff6f664-1f28-45d5-bd73-1ace21709cec)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:c8c2d3e0-6e8a-466f-917a-ff6f3859accc -->
[](c8c2d3e0-6e8a-466f-917a-ff6f3859accc)
--
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]