mikebridge opened a new pull request, #44180:
URL: https://github.com/apache/superset/pull/44180
### SUMMARY
`DATASOURCE_MISSING_ERR` (`views/core.py`) and `PARAMETER_MISSING_ERR`
(`sqllab/query_render.py`) were built with the **eager** gettext alias at
**module scope**, so each was resolved exactly once at import time — no
request, no locale context — and then served in the default locale to every
user forever. This is the mirror image of the bug fixed in #44090 (lazy gettext
inside request handlers), and together they define the convention:
- **eager `__()`** for strings built inside request handlers;
- **lazy `_()`** for module-scope constants, **coerced with `str()` at the
point of use** inside the request.
The point-of-use `str()` also makes this PR independent of #44090's
`LazyString` coercion in `json_error_response` — correct in either merge order.
Also removed: `USER_MISSING_ERR` and `views/core.py`'s duplicate
`PARAMETER_MISSING_ERR`, which had **no consumers anywhere** (dead constants).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — i18n behavior. Before: a French user got "The data source seems to
have been deleted". After: "La source de données semble avoir été effacée".
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/views/test_i18n_constants.py` — the constants are
pinned as `LazyString` (fails pre-fix), `DATASOURCE_MISSING_ERR` renders
per-request-locale under `force_locale("fr"/"en")` (skipped where the fr
catalog isn't compiled — the LazyString pin still guards laziness), and an
inverse-convention tripwire scans the package: no module-level `NAME = __(...)`
may exist in any module binding `__` to eager gettext (fails pre-fix on all
four constants; pairs with #44090's lazy-in-request scan). Reverting the
production change flips the LazyString pins and the tripwire (stash-verified).
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] 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
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
--
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]