Skip to content

fix(db): isolate malformed dialect entry points - #43265

Closed
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/isolate-malformed-dialect-entry-points
Closed

fix(db): isolate malformed dialect entry points#43265
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/isolate-malformed-dialect-entry-points

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Why

Third-party SQLAlchemy dialect entry points are discovered during database engine-spec enumeration. An entry point can load successfully while returning an object that does not satisfy the dialect contract, such as an object without .name. That exception currently escapes the plugin boundary and can break application bootstrap for every user rather than disabling only the malformed connector.

What

Validate and normalize the loaded dialect's name and driver inside the existing third-party entry-point exception boundary. Malformed plugins are logged and skipped. A regression test models an entry point that loads an object without .name, alongside a well-formed entry point that must still register its driver.

Blast radius

Only database connector discovery is affected. Valid SQLAlchemy dialects follow the same path as before; malformed optional plugins now degrade in isolation.

How to test

  • pytest tests/unit_tests/db_engine_specs/test_init.py — 3 passed. Reverting only superset/db_engine_specs/__init__.py to master makes test_malformed_dialect_entry_point_does_not_break_bootstrap fail with the escaping AttributeError, so it is a true regression test.
  • The test asserts both halves of the contract: the malformed entry point is skipped with a warning, and the healthy dialect in the same scan still resolves to {SqliteEngineSpec: {"pysqlite"}}.
  • PRE_COMMIT_HOME=/tmp/pre-commit-superset uvx pre-commit run --files superset/db_engine_specs/__init__.py tests/unit_tests/db_engine_specs/test_init.py — all applicable hooks pass (ruff, ruff-format, mypy). The pylint hook cannot run in this sandbox (pylint: command not found); it is covered by the pre-commit CI job.

Risk & rollback

Low risk: the change broadens the existing plugin isolation boundary and changes the failed-plugin log from debug to warning. Revert this commit to restore the previous behavior.

Review guidance

Please review the exception boundary in superset/db_engine_specs/__init__.py first, then the malformed-contract regression fixture.

Strengthen the regression test so it proves plugin isolation rather than
just absence of an exception: a malformed entry point is skipped with a
warning while a well-formed dialect in the same scan still registers its
driver.
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Aug 17, 2026
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.65%. Comparing base (1991e3f) to head (649323c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43265      +/-   ##
==========================================
- Coverage   66.65%   66.65%   -0.01%     
==========================================
  Files        2874     2874              
  Lines      163784   163784              
  Branches    37798    37798              
==========================================
- Hits       109177   109174       -3     
- Misses      52469    52471       +2     
- Partials     2138     2139       +1     
Flag Coverage Δ
hive 38.13% <100.00%> (ø)
mysql 57.83% <100.00%> (ø)
postgres 57.86% <100.00%> (-0.01%) ⬇️
presto 40.08% <100.00%> (ø)
python 59.25% <100.00%> (-0.01%) ⬇️
sqlite 57.50% <100.00%> (ø)
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi
aminghadersohi marked this pull request as ready for review August 17, 2026 18:59
@dosubot dosubot Bot added change:backend Requires changing the backend data:databases Related to database configurations and connections labels Aug 17, 2026
@bito-code-review

bito-code-review Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #33a30f

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/db_engine_specs/test_init.py - 1
    • Inaccurate inline comment · Line 34-34
      The inline comment on line 34 says "violates the dialect contract: no `name`" but the mock actually has `name = 'malformed'`. The real contract violation is that `load()` returns a dialect object (via `spec=[]`) that lacks the required `name` and `driver` attributes.
Review Details
  • Files reviewed - 2 · Commit Range: 15215a9..649323c
    • superset/db_engine_specs/__init__.py
    • tests/unit_tests/db_engine_specs/test_init.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ 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

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Superseded by #43110, which merged the same fix to get_available_engine_specs with stricter validation (issubclass(dialect, DefaultDialect), name type checking, and adodbapi exclusion) plus equivalent test coverage. Closing as a duplicate.

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

Labels

change:backend Requires changing the backend data:databases Related to database configurations and connections size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant