Skip to content

fix(i18n): make language pack endpoint public for embedded dashboards - #42438

Merged
rusackas merged 2 commits into
apache:masterfrom
prathamesh04:fix/embedded-i18n-language-pack-access
Aug 29, 2026
Merged

rusackas merged 2 commits into
apache:masterfrom
prathamesh04:fix/embedded-i18n-language-pack-access

Conversation

@prathamesh04

@prathamesh04 prathamesh04 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #42433

The /language_pack/<lang>/ endpoint was protected by @has_access, which caused a 302 redirect to /login/ for unauthenticated requests. This silently broke i18n for all embedded dashboards using non-English locales.

Embedded dashboards use a bare fetch() without the guest-token header, so the async language pack fetch in preamble.ts was always blocked. The bootstrap-injected pack path (common_bootstrap_payload) also depends on the JSON catalogs existing on disk - the official Docker image ships only .po files, so when the pack is None the fallback fetch was the only path to load translations, and it was broken.

Root Cause

  1. @has_access blocks embedded guest users: The language pack endpoint requires authenticated access. The embedded SPA bare fetch() has no guest-token header so it gets a 302 to /login/
  2. Official image lacks compiled catalogs: messages.json files are not shipped, so get_language_pack() returns None, making the bootstrap-injected pack empty/null
  3. The async fallback was the only viable path but was blocked by @has_access

Fix

  • Remove @has_access from the language_pack endpoint (translation data is non-sensitive)
  • Add tests verifying the endpoint is accessible without authentication and rejects invalid language codes

Testing Instructions

  1. Run the new unit tests: pytest tests/unit_tests/views/test_base.py::test_language_pack_endpoint_is_public -v
  2. Verify all existing tests still pass: pytest tests/unit_tests/views/test_base.py -v

@dosubot dosubot Bot added authentication Related to authentication embedded i18n Namespace | Anything related to localization labels Jul 26, 2026
@github-actions github-actions Bot added api Related to the REST API and removed i18n Namespace | Anything related to localization embedded labels Jul 26, 2026
@bito-code-review

bito-code-review Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #32e7e7

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: dc80bb1..dc80bb1
    • superset/views/core.py
    • tests/unit_tests/views/test_base.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.19%. Comparing base (12cd259) to head (7a04885).

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #42438       +/-   ##
===========================================
+ Coverage   66.18%   79.19%   +13.00%     
===========================================
  Files        2879     2879               
  Lines      165870   165859       -11     
  Branches    38352    38348        -4     
===========================================
+ Hits       109777   131346    +21569     
+ Misses      53863    32034    -21829     
- Partials     2230     2479      +249     
Flag Coverage Δ
hive 37.93% <ø> (-0.01%) ⬇️
mysql 57.67% <ø> (?)
postgres 57.70% <ø> (?)
presto 39.85% <ø> (-0.01%) ⬇️
python 83.75% <ø> (+26.22%) ⬆️
sqlite 57.39% <ø> (-0.01%) ⬇️
unit 73.96% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
rusackas requested review from Copilot and rusackas July 28, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Makes the /language_pack/<lang>/ endpoint publicly accessible so embedded dashboards can fetch i18n catalogs without being redirected to /login/.

Changes:

  • Removes @has_access from the language_pack view to allow unauthenticated access.
  • Adds unit tests asserting the endpoint is reachable without auth and that invalid language codes are rejected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
superset/views/core.py Removes access-guard decorator from language pack endpoint so embedded fetches don’t redirect to login.
tests/unit_tests/views/test_base.py Adds tests covering public accessibility and invalid language handling for /language_pack/<lang>/.

Comment on lines +345 to +352
def test_language_pack_endpoint_rejects_invalid_lang(app: "SupersetApp") -> None:
"""Invalid language codes are rejected with 400."""
with app.test_client() as client:
resp = client.get("/language_pack/../../../etc/passwd/")
assert resp.status_code in (400, 404)

resp = client.get("/language_pack/en-US/injection/")
assert resp.status_code in (400, 404)
Comment thread tests/unit_tests/views/test_base.py Outdated
Comment on lines +335 to +342
with app.test_client() as client:
resp = client.get("/language_pack/en/")
# The endpoint must be reachable without authentication.
# In the test environment compiled catalogs may not exist, so
# a 404 is acceptable; a 302 to /login/ would indicate the old
# @has_access guard is still in place.
assert resp.status_code in (200, 404)
assert resp.status_code != 302
Comment on lines +323 to +336
def test_language_pack_endpoint_is_public(app: "SupersetApp") -> None:
"""The language pack endpoint must be accessible without authentication.

Translation data is non-sensitive and the embedded dashboard SPA needs to
fetch it with a bare ``fetch()`` (no guest-token header). Previously the
endpoint was protected by ``@has_access`` which caused a 302 redirect to
``/login/`` for unauthenticated requests, silently breaking i18n in
embedded dashboards (issue #42433).

When the compiled catalog exists the endpoint returns 200 with JSON.
When it is missing the endpoint returns 404 (never a 302 to /login/).
"""
with app.test_client() as client:
resp = client.get("/language_pack/en/")
@rusackas

Copy link
Copy Markdown
Member

Thanks for digging into this @prathamesh04! The failing CI (mysql/postgres/sqlite) isn't flaky, it's test_views_are_secured in security_tests.py catching the removed @has_access.

You'll need to add ["Superset", "language_pack"] to the views_allowlist there so the test acknowledges this is intentionally public. There are also a few open Copilot review comments on the new tests worth addressing before we merge.

@prathamesh04

prathamesh04 commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @rusackas for the review! Addressed the Copilot suggestions:

  • Changed redirect assertion to catch any 3xx (not just 302)
  • Added resp.is_json check when 200 is returned
  • Replaced path-injection test cases with a simple unregistered-locale test (zz)

CI is now fully green. Ready for re-review.

@netlify

netlify Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7a04885
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a911912eae2b20008bb5f1a
😎 Deploy Preview https://deploy-preview-42438--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +336 to +341
resp = client.get("/language_pack/en/")
# The endpoint must be reachable without authentication.
# In the test environment compiled catalogs may not exist, so
# a 404 is acceptable; a 302 to /login/ would indicate the old
# @has_access guard is still in place.
assert resp.status_code in (200, 404)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The successful branch only checks the status code and never verifies that the response is JSON containing a language catalog. An unrelated 200 response, HTML response, or empty payload would satisfy this test while still breaking the frontend's fetch() and translation loading contract. [api mismatch]

Severity Level: Major ⚠️
- ❌ Invalid 200 responses can pass the endpoint test.
- ⚠️ `preamble.ts` translation loading contract remains unverified.
- ⚠️ JSON catalog regressions are detected only by embedded users.
Steps of Reproduction ✅
1. Call `/language_pack/en/` through the unauthenticated client at
`tests/unit_tests/views/test_base.py:335-336`.

2. When the catalog exists, `Superset.language_pack()` at `superset/views/core.py:926-930`
returns the file with `mimetype="application/json"`.

3. The test at `tests/unit_tests/views/test_base.py:341` checks only that the status is
not 302; any 200 response, including an unrelated HTML response or an empty body,
satisfies the assertion.

4. Change the handler to return an invalid 200 payload or wrong content type; the test
still passes even though the frontend fetch in `superset-frontend/src/preamble.ts:91-96`
cannot load a usable language catalog. The test should assert the successful branch, JSON
content type, and expected catalog structure, while separately handling environments where
the catalog is mocked or unavailable.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/views/test_base.py
**Line:** 336:341
**Comment:**
	*Api Mismatch: The successful branch only checks the status code and never verifies that the response is JSON containing a language catalog. An unrelated 200 response, HTML response, or empty payload would satisfy this test while still breaking the frontend's `fetch()` and translation loading contract.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread tests/unit_tests/views/test_base.py Outdated
Comment on lines +348 to +352
resp = client.get("/language_pack/../../../etc/passwd/")
assert resp.status_code in (400, 404)

resp = client.get("/language_pack/en-US/injection/")
assert resp.status_code in (400, 404)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: These URLs contain extra path segments, so Flask can return 404 during routing before language_pack executes; because 404 is accepted, the test does not verify that the handler rejects malformed language codes with 400. Pass malformed values within the single <lang> path segment and assert the handler's intended status. [api mismatch]

Severity Level: Major ⚠️
- ❌ Invalid language-code handling is not actually tested.
- ⚠️ Route-level regressions can be mistaken for validation success.
- ⚠️ Path-validation coverage remains incomplete for the public endpoint.
Steps of Reproduction ✅
1. The route is declared as `/language_pack/<lang>/` at `superset/views/core.py:919`, so
`<lang>` accepts one path segment only.

2. Request `/language_pack/../../../etc/passwd/` from
`tests/unit_tests/views/test_base.py:348`; the additional slash-separated segments prevent
Flask routing from invoking `Superset.language_pack()`, so a 404 can occur before the
validation at `superset/views/core.py:921-923`.

3. Request `/language_pack/en-US/injection/` from
`tests/unit_tests/views/test_base.py:351`; the extra `/injection/` segment likewise
exercises routing rather than the handler's regular-expression validation.

4. Replace those requests with single-segment invalid values such as
`/language_pack/en-US/` and `/language_pack/en_US_extra/`; these reach `language_pack()`
and should produce the handler's 400 response at `superset/views/core.py:922-923`, whereas
the current assertions accept 404 and therefore cannot detect a validation regression.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/views/test_base.py
**Line:** 348:352
**Comment:**
	*Api Mismatch: These URLs contain extra path segments, so Flask can return 404 during routing before `language_pack` executes; because 404 is accepted, the test does not verify that the handler rejects malformed language codes with 400. Pass malformed values within the single `<lang>` path segment and assert the handler's intended status.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

bito-code-review Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #a303a9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: dc80bb1..f0ff6cb
    • tests/integration_tests/security_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@prathamesh04
prathamesh04 force-pushed the fix/embedded-i18n-language-pack-access branch from f0ff6cb to 8f1d8db Compare July 30, 2026 03:12
@prathamesh04

Copy link
Copy Markdown
Contributor Author

Thanks @rusackas for the review! Addressed the Copilot suggestions:

  • Changed the redirect assertion to catch any 3xx (not just 302)
  • Added check when 200 is returned
  • Replaced path-injection test cases (, ) with a simple unregistered-locale test

CI is now fully green. Ready for re-review.

@bito-code-review

bito-code-review Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4b6c66

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/views/test_base.py - 1
    • Test docstring may mislead · Line 347-351
      The test correctly accepts 400 and 404 for 'zz', but note that 'zz' passes the regex validation at core.py:922 and would actually return 404 (missing file). Genuinely invalid formats like '99' or 'a-b' are the ones that return 400. The test assertion accepts both, so behavior is correct, but the comment may be slightly misleading.
Review Details
  • Files reviewed - 3 · Commit Range: dc80bb1..8f1d8db
    • superset/views/core.py
    • tests/integration_tests/security_tests.py
    • tests/unit_tests/views/test_base.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas

Copy link
Copy Markdown
Member

I think this just needs a rebase, but otherwise it's looking good! Holler if you want a hand with that.

@rusackas

Copy link
Copy Markdown
Member

@prathamesh04 still conflicting with master. Worth knowing master picked up a language_pack_script endpoint since you opened this one (unauthenticated, content-addressed script tag) that touches the same region of core.py, so the rebase is less trivial than it was a couple weeks ago. That new endpoint doesn't replace the fallback fetch though, so this is still worth landing once it's rebased.

@rusackas
rusackas force-pushed the fix/embedded-i18n-language-pack-access branch from 8f1d8db to 0941e75 Compare August 13, 2026 03:34
@bito-code-review

bito-code-review Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #35c163

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 8319d25..0941e75
    • superset/views/core.py
    • tests/integration_tests/security_tests.py
    • tests/unit_tests/views/test_base.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Remove @has_access from the /language_pack/<lang>/ endpoint to allow
embedded dashboards to fetch translations without authentication.

Embedded dashboards use a bare fetch() without the guest-token header,
so the endpoint returned a 302 redirect to /login/ instead of the
translation catalog. This silently broke i18n for all embedded dashboards
using non-English locales.

The language pack contains only non-sensitive translation strings and
is safe to serve without authentication.

Closes apache#42433
@rusackas
rusackas force-pushed the fix/embedded-i18n-language-pack-access branch from 0941e75 to 7a04885 Compare August 28, 2026 05:13
@bito-code-review

bito-code-review Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1df3c7

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • tests/unit_tests/views/test_base.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: 6f853b4..7a04885
    • superset/views/core.py
    • tests/integration_tests/security_tests.py
    • tests/unit_tests/views/test_base.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit 1c8d58a into apache:master Aug 29, 2026
73 checks passed
rusackas pushed a commit that referenced this pull request Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API authentication Related to authentication size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded dashboards are never translated: the embedded entry point does not run the i18n bootstrap

3 participants