Antonio-RiveroMartnez opened a new pull request, #42996:
URL: https://github.com/apache/superset/pull/42996

   ### SUMMARY
   
   Preserve neutral provenance for SQLAlchemy exceptions emitted by `Database` 
model engines.
   
   Each newly created engine receives one instance-level `handle_error` 
listener immediately after successful creation and before cache publication. 
The listener marks the SQLAlchemy exception without inspecting, wrapping, 
replacing, or otherwise altering it.
   
   Python extensions can query the marker through the neutral public helper:
   
   ```python
   from superset.databases.error_provenance import is_database_engine_error
   ```
   
   The helper returns `False` when the marker is absent. If a later 
`handle_error` listener replaces the marked exception, the replacement remains 
unmarked because it has separate provenance.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable; no UI changes.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest -q tests/unit_tests/databases/error_provenance_test.py
   pytest -q tests/unit_tests/models/core_test.py
   pytest -q tests/integration_tests/model_tests.py \
     -k 'impersonate_user_presto or adjust_engine_params_mysql or 
impersonate_user_trino or impersonate_user_hive or test_get_sqla_engine'
   ```
   
   Validation completed:
   
   - Provenance unit tests: 7 passed.
   - Full `tests/unit_tests/models/core_test.py`: 76 passed.
   - Staged-file pre-commit: all hooks passed.
   - The selected integration tests could not start because the local metadata 
database lacks the `css_templates` table; setup failed before the selected test 
bodies ran.
   
   Coverage verifies connect-time and statement-time marking, outward exception 
identity, public and private engine paths, cache behavior, safe 
marker-assignment failure, listener replacement semantics, and mocked engine 
creation paths.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   The implementation targets SQLAlchemy 1.4.54's `handle_error` and 
`ExceptionContext.sqlalchemy_exception` contracts. These contracts and listener 
ordering semantics should be reviewed during a SQLAlchemy upgrade.
   


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