Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016
Open
deepujain wants to merge 1 commit intoapache:mainfrom
Open
Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016deepujain wants to merge 1 commit intoapache:mainfrom
deepujain wants to merge 1 commit intoapache:mainfrom
Conversation
…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).
1c4eb96 to 7839403 Compare This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 byconf.mask_secrets(). After the reset, these secrets appear in plaintext in task subprocess logs when printed viaprint()orstructlog.The fix calls
conf.mask_secrets()immediately afterreset_secrets_masker()to re-register config-level secrets before the task subprocess is forked.Changes
task-sdk/src/airflow/sdk/execution_time/supervisor.py— Afterreset_secrets_masker(), conditionally callconf.mask_secrets()whenairflow.configurationis loaded (always true for worker-spawned supervisors) to re-register config secrets in the SDK masker.task-sdk/tests/task_sdk/execution_time/test_supervisor.py— Regression test verifying that config secrets are re-masked afterreset_secrets_masker()+conf.mask_secrets().Fixes #63921