You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Abdulrehman-PIAIC80387 (via GitHub)" <gi...@apache.org> on 2026/04/23 08:32:33 UTC
[PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Abdulrehman-PIAIC80387 opened a new pull request, #39585:
URL: https://github.com/apache/superset/pull/39585
### SUMMARY
When \`BABEL_DEFAULT_LOCALE\` is set to a locale that is not a key in the \`LANGUAGES\` config dict, \`LanguagePicker.tsx\` crashes the entire app with:
\`\`\`
TypeError: Cannot read properties of undefined (reading 'flag')
\`\`\`
**Root cause:** The component accesses \`languages[locale].flag\` and \`languages[langKey].flag\` unconditionally. If the matching entry doesn't exist (user's \`LANGUAGES\` config doesn't include every possible locale, or an entry is missing the \`flag\` property), the app breaks at bundle load.
**Fix:** Add optional chaining (\`?.\`) and a fallback for the \`flag\` className so a missing locale/entry renders harmlessly instead of throwing.
Fixes #39163
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** App fails to load with a blank page. DevTools console shows \`TypeError: Cannot read properties of undefined (reading 'flag')\`.
**After:** App loads normally. If the flag icon can't be resolved for the current locale, the \`<i>\` element simply renders with an empty class — no crash.
### TESTING INSTRUCTIONS
1. In \`superset_config.py\`, set:
\`\`\`python
BABEL_DEFAULT_LOCALE = "de"
LANGUAGES = {
"en": {"flag": "us", "name": "English"},
"fr": {"flag": "fr", "name": "French"},
}
\`\`\`
2. Start Superset and open it in the browser
3. **Before the fix:** blank page, \`TypeError\` in console
4. **With the fix:** page loads normally, language menu still renders
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #39163
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4302951459
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ac13d36e3b687c4860be088785bbfca94a86fbf0 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e9d922d2111c000828d8da |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39585--superset-docs-preview.netlify.app](https://deploy-preview-39585--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39585--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on code in PR #39585:
URL: https://github.com/apache/superset/pull/39585#discussion_r3141699233
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
@@ -61,9 +61,9 @@ export const useLanguageMenuItems = ({
key: langKey,
label: (
<StyledLabel className="f16">
- <i className={`flag ${languages[langKey].flag}`} />
- <Typography.Link href={languages[langKey].url}>
- {languages[langKey].name}
+ <i className={`flag ${languages[langKey]?.flag ?? ''}`} />
Review Comment:
```suggestion
<i className={`flag ${languages[langKey]?.flag ?? 'us'}`} />
```
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
Review Comment:
```suggestion
flag?: string;
url?: string;
name?: string;
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "Abdulrehman-PIAIC80387 (via GitHub)" <gi...@apache.org>.
Abdulrehman-PIAIC80387 commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4318962857
Thanks for the review @hainenber. I've applied all three suggestions:
- `?? 'us'` fallback on both lines (current locale + per-language menu items)
- `Languages` interface fields are now optional (`flag?`, `url?`, `name?`)
Please take another look when you have time and let me know if any further changes are needed.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on code in PR #39585:
URL: https://github.com/apache/superset/pull/39585#discussion_r3141700284
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
Review Comment:
```suggestion
flag?: string;
url?: string;
name?: string;
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4302928997
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4434464685
Goin' for the merge!!! Thanks for the PR, and let me know if anyone spots anything on master that needs further dialing in!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on code in PR #39585:
URL: https://github.com/apache/superset/pull/39585#discussion_r3141701547
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
@@ -61,9 +61,9 @@ export const useLanguageMenuItems = ({
key: langKey,
label: (
<StyledLabel className="f16">
- <i className={`flag ${languages[langKey].flag}`} />
- <Typography.Link href={languages[langKey].url}>
- {languages[langKey].name}
+ <i className={`flag ${languages[langKey]?.flag ?? ''}`} />
Review Comment:
```suggestion
<i className={`flag ${languages[langKey]?.flag ?? 'us'}`} />
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on code in PR #39585:
URL: https://github.com/apache/superset/pull/39585#discussion_r3141701980
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
@@ -61,9 +61,9 @@ export const useLanguageMenuItems = ({
key: langKey,
label: (
<StyledLabel className="f16">
- <i className={`flag ${languages[langKey].flag}`} />
- <Typography.Link href={languages[langKey].url}>
- {languages[langKey].name}
+ <i className={`flag ${languages[langKey]?.flag ?? ''}`} />
Review Comment:
Without a placeholder value, this will show an unknown flag with question mark.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on code in PR #39585:
URL: https://github.com/apache/superset/pull/39585#discussion_r3141699233
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
@@ -61,9 +61,9 @@ export const useLanguageMenuItems = ({
key: langKey,
label: (
<StyledLabel className="f16">
- <i className={`flag ${languages[langKey].flag}`} />
- <Typography.Link href={languages[langKey].url}>
- {languages[langKey].name}
+ <i className={`flag ${languages[langKey]?.flag ?? ''}`} />
Review Comment:
```suggestion
<i className={`flag ${languages[langKey]?.flag ?? 'us'}`} />
```
##########
superset-frontend/src/features/home/LanguagePicker.tsx:
##########
@@ -75,7 +75,7 @@ export const useLanguageMenuItems = ({
type: 'submenu' as const,
label: (
<span className="f16" aria-label={t('Languages')}>
- <i className={`flag ${languages[locale].flag}`} />
+ <i className={`flag ${languages[locale]?.flag ?? ''}`} />
Review Comment:
```suggestion
<i className={`flag ${languages[locale]?.flag ?? 'us'}`} />
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4319480494
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4318565808
Also you'll need to change the interface `Languages` in the same file to be optional fields for `flag`, `url` and `name`.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #39585:
URL: https://github.com/apache/superset/pull/39585
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): prevent LanguagePicker crash when locale is missing from LANGUAGES config [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39585:
URL: https://github.com/apache/superset/pull/39585#issuecomment-4303028071
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39585?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 64.58%. Comparing base ([`bc2ffc6`](https://app.codecov.io/gh/apache/superset/commit/bc2ffc66e5181a369c918b4aa080d126a3c15ab4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ac13d36`](https://app.codecov.io/gh/apache/superset/commit/ac13d36e3b687c4860be088785bbfca94a86fbf0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 3 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #39585 +/- ##
=======================================
Coverage 64.58% 64.58%
=======================================
Files 2564 2564
Lines 133576 133578 +2
Branches 31033 31035 +2
=======================================
+ Hits 86271 86273 +2
Misses 45813 45813
Partials 1492 1492
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39585/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/39585/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.53% <100.00%> (+<0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/39585?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org