bito-code-review[bot] commented on code in PR #34565:
URL: https://github.com/apache/superset/pull/34565#discussion_r2837312057


##########
superset/views/base.py:
##########
@@ -479,7 +479,7 @@ def cached_common_bootstrap_data(  # pylint: 
disable=unused-argument
     if isinstance(locale, Locale):
         language = locale.language
     elif isinstance(locale, str):
-        language = locale
+        language = locale.split("_")[0]
     else:
         language = app.config.get("BABEL_DEFAULT_LOCALE", "en")

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incorrect locale language extraction</b></div>
   <div id="fix">
   
   The language extraction logic incorrectly handles locale strings with 
hyphens (e.g., 'de-DE' becomes 'de-DE' instead of 'de'), as it only splits on 
underscores. This can lead to incorrect language settings in the frontend. 
Also, the isinstance check for Locale is dead code since the parameter is now 
str | None. Consider normalizing separators by replacing hyphens with 
underscores before splitting.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       if isinstance(locale, str):
           language = locale.replace("-", "_").split("_")[0]
       else:
           language = app.config.get("BABEL_DEFAULT_LOCALE", "en")
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #97c7da</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to