korbit-ai[bot] commented on code in PR #34565:
URL: https://github.com/apache/superset/pull/34565#discussion_r2255273133
##########
superset/views/base.py:
##########
@@ -383,7 +382,7 @@ def cached_common_bootstrap_data( # pylint:
disable=unused-argument
and bool(available_specs[GSheetsEngineSpec])
)
- language = locale.language if locale else "en"
+ language = locale.split("_")[0] if locale else "en"
Review Comment:
### Unsafe Locale String Splitting <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The code assumes the locale string will always contain an underscore
character (_), which may not be true for all locale formats.
###### Why this matters
If a locale string without an underscore is passed (e.g., 'es', 'fr'), the
split operation will throw an IndexError and break the language selection
functionality.
###### Suggested change ∙ *Feature Preview*
Add a safe fallback when splitting the locale string:
```python
language = locale.split("_")[0] if locale and "_" in locale else (locale or
"en")
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d35bcf4e-0d11-40a2-986b-08b183be285e/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d35bcf4e-0d11-40a2-986b-08b183be285e?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d35bcf4e-0d11-40a2-986b-08b183be285e?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d35bcf4e-0d11-40a2-986b-08b183be285e?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d35bcf4e-0d11-40a2-986b-08b183be285e)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:44257e47-ccab-4eb7-9bcf-1fcc2b14947f -->
[](44257e47-ccab-4eb7-9bcf-1fcc2b14947f)
--
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]