bito-code-review[bot] commented on PR #44180:
URL: https://github.com/apache/superset/pull/44180#issuecomment-5642059280

   <!-- Bito Reply -->
   The flagged issue is correct. Constructing `CertificateException()` at the 
module level or outside a request context triggers `gettext` to attempt 
translation immediately, which fails because the Flask application context is 
not yet available, resulting in a `RuntimeError`.
   
   To resolve this, you should use `lazy_gettext` (often aliased as `_`) 
instead of `gettext` (aliased as `__`) for module-level constants. This defers 
translation until the string is actually accessed within a request context. In 
`superset/exceptions.py`, you can update the `CertificateException` to accept a 
lazy string or handle the translation lazily within the `__init__` method.
   
   Would you like me to fetch all other comments on this PR to validate them 
and implement fixes for the rest?
   
   **superset/exceptions.py**
   ```
   from flask_babel import lazy_gettext as _
   
   class CertificateException(SupersetException):
       def __init__(self, message: str = "", ...):
           super().__init__(
               message=message or _("Invalid certificate"),
               ...
           )
   ```


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