aminghadersohi opened a new pull request, #43110:
URL: https://github.com/apache/superset/pull/43110
### SUMMARY
`get_available_engine_specs()` enumerates every installed
`sqlalchemy.dialects` entry point and reads `dialect.name` **unguarded**:
```python
for ep in entry_points(group="sqlalchemy.dialects"):
try:
dialect = ep.load()
except Exception as ex:
logger.debug(...)
else:
backend = dialect.name # <-- unguarded
driver = getattr(dialect, "driver", dialect.name)
```
If a third-party entry point **loads successfully but does not resolve to a
usable dialect** — e.g. a malformed `name = package:module` entry point that
yields a *module* (which has no `.name`) — the `AttributeError` aborts the
whole enumeration. Because `get_available_engine_specs()` runs inside
`common_bootstrap_payload()`, this 500s **every page that builds the
bootstrap** (e.g. `/welcome/`), not just that one connector — the whole app
becomes unusable.
Real-world trigger: `sqlalchemy-exasol` 7.1.1+ registers `exa =
sqlalchemy_exasol:base`, which `ep.load()` resolves to the `base` **module**;
`module.name` → `AttributeError` → every page 500s under SQLAlchemy 2.0.
The native-dialect loop directly above is already defensive
(`issubclass(dialect, DefaultDialect)`, `hasattr(dialect, "driver")`,
per-dialect `try/except`). This makes the third-party loop equally defensive:
if the loaded object has no usable `.name`, **skip it with a `logger.warning`
and continue**. A malformed driver then degrades to "that one connector is
unavailable" instead of "the app is down".
### TESTING INSTRUCTIONS
`pytest tests/unit_tests/db_engine_specs/test_init.py`
Adds `test_get_available_engine_specs_skips_malformed_dialect_entry_point`:
registers a bogus `sqlalchemy.dialects` entry point whose `load()` returns a
module (no `.name`) and asserts `get_available_engine_specs()` skips it (with a
warning) instead of raising. The test raises `AttributeError` on `master` and
passes with this change.
### 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))
- [ ] 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]