dabla opened a new pull request, #74147:
URL: https://github.com/apache/airflow/pull/74147

   `Connection.extra_dejson` masks the extra's secrets with a synchronous call 
to the supervisor. When a hook reads it on an event loop with another async 
call in flight (an async task running items concurrently, a trigger), that 
raises `DeadlockImminentError`.
   
   Airflow 3.3.2+ has `Connection.aextra_dejson()` (#71890, backported in 
#72895), but providers that still support older Airflow versions can't call it 
directly. Async hooks therefore deserialize the raw extra themselves 
(`json.loads(conn.extra)`, e.g. #72130 and the msgraph hook), which skips 
masking the individual values of the extra.
   
   This adds `get_async_extra_dejson(conn)` next to `get_async_connection()` in 
`airflow.providers.common.compat.connection`:
   
   ```python
   from airflow.providers.common.compat.connection import get_async_connection, 
get_async_extra_dejson
   
   conn = await get_async_connection(self.conn_id)
   extras = await get_async_extra_dejson(conn)
   ```
   
   | Airflow | Path | Secrets masked |
   |---|---|---|
   | 3.3.2+ | `await conn.aextra_dejson()` | yes, asynchronously |
   | older (3.x, 2.x) | `conn.extra_dejson` in a worker thread 
(`asgiref.sync_to_async`), where blocking on the supervisor is safe — the same 
fallback `get_async_connection()` uses for `get_connection()` | yes |
   
   Follow-ups will use it in async hook paths (async `aget_conn()` for 
`OpenAIHook` and `PydanticAIHook`, and the existing async hooks that 
`json.loads` the extra today).
   
   Tests cover the `aextra_dejson()` path (while `extra_dejson` raises), the 
fallback running off the event-loop thread, and a real `Connection` with and 
without an extra.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Opus 5.5
   
   Generated-by: Claude Opus 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]

Reply via email to