Skip to content

Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016

Draft
deepujain wants to merge 2 commits intoapache:mainfrom
deepujain:fix-63921-remask-config-secrets-after-reset
Draft

Fix config secrets not masked in task logs after reset_secrets_masker (#63921)#64016
deepujain wants to merge 2 commits intoapache:mainfrom
deepujain:fix-63921-remask-config-secrets-after-reset

Conversation

@deepujain
Copy link
Contributor

@deepujain deepujain commented Mar 20, 2026

Summary

reset_secrets_masker() in supervise() 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 conf.mask_secrets(). After the reset, these secrets appear in plaintext in task subprocess logs when printed via print() or structlog.

The fix calls conf.mask_secrets() immediately after reset_secrets_masker() to re-register config-level secrets before the task subprocess is forked.

Changes

  • task-sdk/src/airflow/sdk/execution_time/supervisor.py — After reset_secrets_masker(), conditionally call conf.mask_secrets() when airflow.configuration is 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 after reset_secrets_masker() + conf.mask_secrets().

Fixes #63921

@deepujain deepujain force-pushed the fix-63921-remask-config-secrets-after-reset branch from 1c4eb96 to 7839403 Compare March 20, 2026 20:51
@potiuk
Copy link
Member

potiuk commented Mar 22, 2026

@deepujain This PR has been converted to draft because it does not yet meet our Pull Request quality criteria.

Issues found:

  • Provider tests: Failing: provider distributions tests / Compat 2.11.1:P3.10:, provider distributions tests / Compat 3.0.6:P3.10:, provider distributions tests / Compat 3.1.8:P3.10:, Integration and System Tests / Integration: providers drill. Run provider tests with breeze run pytest <provider-test-path> -xvs. See Provider tests docs.

What to do next:

  • The comment informs you what you need to do.
  • Fix each issue, then mark the PR as "Ready for review" in the GitHub UI - but only after making sure that all the issues are fixed.
  • There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates.
  • Maintainers will then proceed with a normal review.

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.

@potiuk potiuk marked this pull request as draft March 22, 2026 11:33
@potiuk
Copy link
Member

potiuk commented Mar 22, 2026

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).
@deepujain deepujain force-pushed the fix-63921-remask-config-secrets-after-reset branch from 7839403 to 002a237 Compare March 27, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secrets from Airflow configuration are not masked in task logs

2 participants