SEPURI-SAI-KRISHNA opened a new pull request, #42411:
URL: https://github.com/apache/superset/pull/42411

   ### SUMMARY
   
   `DatabaseExtraValidationError` builds its message with `%{key}s` instead of
   `%(key)s`:
   
   ```python
   "The metadata_params in Extra field is not configured correctly. "
   "The key %{key}s is invalid.",
   key=key,
   ```
   
   `flask_babel` performs `string % variables`, and `%{` is not a valid
   conversion specifier, so rendering the message raises:
   
   ```
   ValueError: unsupported format character '{' (0x7b) at index 73
   ```
   
   Because the class uses `lazy_gettext`, the failure is deferred until the
   message is actually rendered — e.g. when marshmallow serializes the 
validation
   error into a response — rather than raising at construction time.
   
   The sibling `DatabaseExtraJSONValidationError` directly above it already uses
   the correct `%(json_error)s` form, which is what makes this a typo rather 
than
   an intentional format.
   
   **Scope note:** `DatabaseExtraValidationError` is not raised anywhere in the
   codebase today, so there is no user-visible impact. This fixes the latent
   defect before a caller is added, and pins the interpolation of both messages
   with tests so the same typo cannot return. Happy to close this if maintainers
   would rather remove the unused classes instead — I avoided deleting them 
since
   they are importable and may be referenced by downstream forks or plugins.
   
   Found while AST-scanning every `_()` / `__()` call in `superset/` for
   placeholder/kwarg mismatches.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable — error message text, and the class is currently unreachable.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/commands/databases/exceptions_test.py
   ```
   
   Adds a test module covering both exception classes. Each test forces the lazy
   string to render and asserts the value is interpolated with no `%` left over.
   
   To confirm it is a genuine regression test, revert the one-character change 
and
   re-run — `test_database_extra_validation_error_interpolates_key` fails with
   `ValueError: unsupported format character '{'`.
   
   ### 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
   


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