diogosilva30 opened a new pull request, #77338:
URL: https://github.com/apache/airflow/pull/77338
Airflow 3.4 derives the async metadata engine URL from `sql_alchemy_conn`
and only translates `sslmode` for asyncpg. A MySQL URL that sets mysqlclient's
`ssl_mode` (for example `mysql+mysqldb://...?ssl_mode=REQUIRED`) reaches
aiomysql/asyncmy unchanged, and neither has that connect argument:
```
TypeError: connect() got an unexpected keyword argument 'ssl_mode'
```
On the Execution API every `PATCH /execution/task-instances/{id}/run` then
returns a 500, so no task can start, and the scheduler logs "task state changed
externally" for each one. On a server that only accepts encrypted connections,
dropping `ssl_mode` is not an option either, so the async drivers need an
`ssl.SSLContext`. A URL cannot carry one, which is why this is handled in
`create_async_metadata_engine` rather than in `_get_async_conn_uri_from_sync`.
That also covers an explicit `sql_alchemy_conn_async`.
Mapping, using mysqlclient's mode names (case-insensitive):
- `DISABLED`: parameter dropped, no TLS.
- `REQUIRED`: TLS without certificate or hostname verification, which is
what mysqlclient does for `REQUIRED`.
- `VERIFY_CA` / `VERIFY_IDENTITY`: verified against `ssl_ca` (or the system
store), hostname checked only for `VERIFY_IDENTITY`. `ssl_cert`/`ssl_key` are
loaded when given.
- Anything else, including `PREFERRED`, raises `ValueError`. The async
drivers cannot fall back to plaintext, and those values already failed with the
`TypeError` above.
- An `ssl` entry in `[database] sql_alchemy_connect_args_async` takes
precedence.
Checks run:
- `uv run --project airflow-core pytest
airflow-core/tests/unit/core/test_settings.py`: 74 passed, 10 skipped
(backend-specific). The new tests fail without the change.
- Against a real MySQL 8.4 with both drivers: `REQUIRED` and `VERIFY_CA`
connect over TLS, `DISABLED` connects without TLS, `VERIFY_IDENTITY` is refused
when the certificate does not match the host, `PREFERRED` raises.
- `prek` pre-commit and manual-stage hooks on the changed files, including
`mypy-airflow-core`.
- Not run: `breeze verify` and the full CI matrix.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Sonnet 5.5)
Generated-by: Claude Code (Sonnet 5.5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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]