Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016
Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016deepujain wants to merge 4 commits intoapache:mainfrom
Conversation
1c4eb96 to
7839403
Compare
|
@deepujain This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack. |
|
See comments in related issues. |
…apache#63921) reset_secrets_masker() clears all patterns from the SDK secrets masker, including config-level secrets (webserver.secret_key, api.secret_key, api_auth.jwt_secret) that were registered at startup. After the reset, task subprocess logs no longer mask these secrets. Re-register config secrets by calling conf.mask_secrets() immediately after the reset when airflow.configuration is available (which is always the case since supervisors are spawned from workers).
7839403 to
002a237
Compare
|
Pushed a no-op commit to rerun the required checks. Validation evidence for the fix path: the targeted regression for re-masking config secrets passed locally, the full |
There was a problem hiding this comment.
Pull request overview
This PR fixes a Task SDK regression where calling reset_secrets_masker() inside supervise() clears previously registered config-derived secret masks, causing sensitive config values (e.g. API/webserver/JWT secrets) to appear in task subprocess logs.
Changes:
- Add
AirflowSDKConfigParser.mask_secrets()to (re-)register sensitive config values (and certain secrets-backend kwarg env vars) with the SDK secrets masker. - Call
conf.mask_secrets()immediately afterreset_secrets_masker()insupervise()to restore config masking before launching the task subprocess. - Add a regression test intended to validate re-masking behavior after a masker reset.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| task-sdk/src/airflow/sdk/configuration.py | Adds SDK-native conf.mask_secrets() to register sensitive config/env-derived values for masking. |
| task-sdk/src/airflow/sdk/execution_time/supervisor.py | Re-applies config secret masking right after reset_secrets_masker() in supervise(). |
| task-sdk/tests/task_sdk/execution_time/test_supervisor.py | Adds a regression test around reset + re-mask behavior. |
|
Picked up the follow-up review items on this branch. I moved |
Title: Fix config secrets not masked in task logs after reset_secrets_masker (#63921)
Summary
reset_secrets_masker()insupervise()clears all patterns from the SDK secrets masker — including config-level secrets (webserver.secret_key,api.secret_key,api_auth.jwt_secret) that were registered at startup by the SDK configuration layer. After the reset, these secrets appear in plaintext in task subprocess logs when printed viaprint()orstructlog.The fix adds an SDK-native
conf.mask_secrets()implementation and calls it immediately afterreset_secrets_masker()so those config-level secrets are re-registered in the SDK masker before the task subprocess is forked. This avoids depending onairflow-coremasking internals during provider compatibility runs.Changes
task-sdk/src/airflow/sdk/configuration.py— Add SDK-nativeconf.mask_secrets()support so the task SDK can re-register sensitive config values without relying onairflow-core.task-sdk/src/airflow/sdk/execution_time/supervisor.py— Call the SDK config parser’sconf.mask_secrets()immediately afterreset_secrets_masker()to restore config masking in task subprocesses.task-sdk/tests/task_sdk/execution_time/test_supervisor.py— Regression test verifying thatapi.secret_key,webserver.secret_key, andapi_auth.jwt_secretare re-masked afterreset_secrets_masker()+conf.mask_secrets().Test plan
test_supervise_remasks_config_secrets_after_resetFixes #63921