Mask URL-encoded connection password in task SDK #74618
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:
docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
Thanks for the review.
_amask_connection_secrets and handle_get_connection. I checked that all three tests (sync, async, handler) fail without the fix.quote_plus: Airflow itself only encodes the password with quote(..., safe="") (Connection.get_uri in both core and the SDK), so a space becomes %20, never +. Parsing uses unquote, not unquote_plus, so a literal + in a URI is already the decoded password and is masked as-is. I didn't find a path that emits the quote_plus form.🤖 Generated with Claude Code
@amoghrajesh could you take a look when you have a moment? I addressed the review from @developer-rpai: the async masking path and handle_get_connection now have regression tests, and all three fail without the fix. The CI workflows are still waiting on approval since this is my first PR here. Happy to change anything.
Thanks @Rishavbhattarai, the async and handle_get_connection tests cover what I was after, and the quote_plus answer makes sense since get_uri only ever uses quote with safe="". LGTM from my side.
ashb
Rishavbhattarai
Connections supplied as URIs (e.g.
AIRFLOW_CONN_AZURE_DEFAULT) carry the password percent-encoded. The task SDK only masked the decoded password, so a secret containing special characters leaked in its encoded form (e.g. viaprintenvin a BashOperator). The coreConnectionmodel already masksquote(password); the task SDK paths did not.quote(password, safe="")in_mask_connection_secrets,_amask_connection_secretsandhandle_get_connection.safe=""in the core model too, to matchConnection.get_uri(defaultquoteleaves/unencoded).closes: #38144
---
##### Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines