Skip to content

fix(i18n): wrap table access error message with gettext for translation#38489

Open
Harshit-Tiwary wants to merge 2 commits intoapache:masterfrom
Harshit-Tiwary:first-contribution
Open

fix(i18n): wrap table access error message with gettext for translation#38489
Harshit-Tiwary wants to merge 2 commits intoapache:masterfrom
Harshit-Tiwary:first-contribution

Conversation

@Harshit-Tiwary
Copy link

@Harshit-Tiwary Harshit-Tiwary commented Mar 7, 2026

User description

SUMMARY

Wrap the SQLLab table access error message with gettext _() so that
it becomes translatable via Superset's internationalization (i18n) system.

Previously the message was returned as a raw string and therefore could
not be translated.

This change ensures the error message can be localized properly.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable.

TESTING INSTRUCTIONS

  1. Trigger a table access permission error in SQLLab.
  2. Verify that the error message is wrapped with _() and can be translated.

ADDITIONAL INFORMATION

This improves i18n support for SQLLab error messages.


CodeAnt-AI Description

Make SQLLab table-access error translatable and use double-quoted table names

What Changed

  • The SQLLab table-access denial message is now wrapped for translation so it can appear in the user's language.
  • Table names in that error are shown with double quotes instead of backticks.
  • The message explicitly mentions the required permissions ('all_database_access' or 'all_datasource_access') in a translatable string.

Impact

✅ Localized SQLLab permission errors
✅ Consistent table-name quoting in error messages
✅ Translatable denied-table messages

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 7, 2026

Code Review Agent Run #38b2ea

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 22df96c..22df96c
    • superset/security/manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the i18n Namespace | Anything related to localization label Mar 7, 2026
@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Mar 7, 2026
ViewMenuModelView,
)
from flask_babel import lazy_gettext as _
from flask_babel import gettext as _
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Importing gettext as _ means all uses of _() in this module (many of which are at class definition/import time) will be translated eagerly in the default locale instead of lazily per-request, breaking i18n because strings like filter names will no longer respect the current user's locale; use lazy_gettext for _ instead so existing call sites remain lazily translated while still allowing the new error message to be localized. [logic error]

Severity Level: Major ⚠️
- ⚠️ User list filter label `username` not localized per locale.
- ⚠️ Any class-level `_()` strings ignore current user locale.
- ⚠️ Inconsistent i18n: some filters localized, others stuck default.
Suggested change
from flask_babel import gettext as _
from flask_babel import lazy_gettext as _
Steps of Reproduction ✅
1. Start Superset with the PR code so that `superset/security/manager.py` is imported and
`_` is bound to eager gettext via `from flask_babel import gettext as _` at line 47.

2. During import of `SupersetSecurityManager` (same file), class attributes like
`ExcludeUsersFilter.name = _("username")` are evaluated once at import time, storing a
plain `str` in the default server locale rather than a lazy object.

3. Access any user-listing API or view that uses `SupersetUserApi.base_filters =
[["username", ExcludeUsersFilter, lambda: []]]` (defined in
`superset/security/manager.py`), so the UI renders the filter label from
`ExcludeUsersFilter.name`.

4. Change the active locale for a different request (e.g., configure a different UI
language for another user or browser session) and hit the same user-listing endpoint
again; observe that the filter label text remains in the original import-time language
because it was translated eagerly, whereas other filters defined in modules using
`lazy_gettext as _` (e.g. `superset/charts/filters.py`) correctly follow the per-request
locale.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/security/manager.py
**Line:** 47:47
**Comment:**
	*Logic Error: Importing `gettext` as `_` means all uses of `_()` in this module (many of which are at class definition/import time) will be translated eagerly in the default locale instead of lazily per-request, breaking i18n because strings like filter names will no longer respect the current user's locale; use `lazy_gettext` for `_` instead so existing call sites remain lazily translated while still allowing the new error message to be localized.

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.
👍 | 👎

@github-actions github-actions bot removed the i18n Namespace | Anything related to localization label Mar 7, 2026
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Mar 7, 2026

Code Review Agent Run #4c5a87

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 22df96c..2780808
    • superset/security/manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant