Repository navigation
Description
Apache Airflow version
3.2.2 (apache-airflow-task-sdk 1.2.2). Also present on main at 79fa2e6.
If "Other Airflow 2/3 version" selected, which one?
No response
What happened?
The deprecation shim at airflow.sdk.execution_time.secrets_masker tells you to migrate to airflow.sdk._shared.secrets_masker. For mask_secret its own code deliberately does something else, and the two are not equivalent: airflow.sdk.log.mask_secret also forwards the secret to the supervisor, airflow.sdk._shared.secrets_masker.mask_secret does not. Following the warning silently drops supervisor masking.
The warning says _shared (L33-L37):
warnings.warn(
"Importing from 'airflow.sdk.execution_time.secrets_masker' is deprecated and will be "
"removed in a future version. Please use 'airflow.sdk._shared.secrets_masker' instead.",
DeprecatedImportWarning,
stacklevel=2,
)The code hands you airflow.sdk.log (L43-L47):
def __getattr__(name: str):
if name == "mask_secret":
from airflow.sdk.log import mask_secret
return mask_secretConfirmed by object identity on 3.2.2:
shim.mask_secret is airflow.sdk.log.mask_secret -> True
shim.mask_secret is airflow.sdk._shared.secrets_masker.mask_secret -> False
That special case is correct, and it is load bearing. airflow.sdk.log.mask_secret registers with the shared masker and notifies the supervisor (log.py L250-L266):
def mask_secret(secret: JsonValue, name: str | None = None) -> None:
"""Mask a secret in both task process and supervisor process. ..."""
_secrets_masker().add_mask(secret, name)
with suppress(Exception):
from airflow.sdk.execution_time import task_runner
from airflow.sdk.execution_time.comms import MaskSecret
if comms := getattr(task_runner, "SUPERVISOR_COMMS", None):
comms.send(MaskSecret(value=secret, name=name))The _shared one the warning recommends stops at the first line (secrets_masker.py L92-…); there is no SUPERVISOR_COMMS reference anywhere in that module. Under AIP-72 the supervisor is a separate process, so a secret registered only through _shared can still appear in supervisor log output.
The failure is silent. Both modules import, both expose mask_secret, both accept the call and return None. A test asserting the symbol is importable and callable passes against either one, including the one that misses the supervisor.
What you think should happen instead?
The warning text and the module docstring should name airflow.sdk.log for mask_secret, matching what __getattr__ already does. Either carve out the exception in the message, or drop the special case so the message becomes true.
The shim came in with #54915, added defensively after #54449 removed the path, so this reads as incidental rather than intended.
How to reproduce
import warnings
warnings.simplefilter("ignore")
import airflow.sdk.execution_time.secrets_masker as shim
import airflow.sdk._shared.secrets_masker as shared
import airflow.sdk.log as sdklog
print(shim.mask_secret is sdklog.mask_secret) # True, what the shim gives you
print(shim.mask_secret is shared.mask_secret) # False, what the warning tells you to useOperating System
macOS 15 (not OS specific)
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
No response
Anything else?
Two engineers migrating the same codebase independently read the deprecation message, moved to airflow.sdk._shared.secrets_masker, and ended up with weaker masking than they started with. Neither noticed, because every wrong answer in this area imports and runs fine. The human readable guidance is the only signal most people act on, and right now it points away from the implementation the shim itself chose.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
Merge branch 'main' into fix/apache#70875
kutsibalci commentedon Aug 6, 2026
@1fanwang you ticked "willing to submit a PR" — are you still working on this? If so I will stay out of the way.
If you would rather not, I am happy to pick it up. I checked the three files on current
mainbefore offering, and the asymmetry still holds:airflow.sdk._shared.secrets_masker, but its__getattr__special-casesmask_secrettoairflow.sdk.log;airflow.sdk.log.mask_secretcallsadd_maskand sendsMaskSecretoverSUPERVISOR_COMMS;_sharedone callsadd_maskonly —SUPERVISOR_COMMS,MaskSecretandtask_runnerappear zero times in that module.So following the warning does drop supervisor-side masking. (Read from the sources rather than executed — I have not run a task under a supervisor to watch it happen, so I am reporting what the code says, not an observed leak.)
One thing I would want a maintainer's view on first, since the issue offers two directions and they are not equivalent:
__getattr__already routesmask_secrettoairflow.sdk.log, so the warning and the module docstring would nameairflow.sdk.logfor that symbol andairflow.sdk._shared.secrets_maskerfor the rest. Smallest change, and it makes the guidance match what the shim actually does.I would go with the first unless the special case is meant to be temporary. Happy either way — I just did not want to open a PR that picks a direction on someone else's issue.
1fanwang commentedon Aug 6, 2026
thanks however I see a pr already #70883
kutsibalci commentedon Aug 6, 2026
Thanks — I had missed #70883, and it takes the direction I would have taken (correct the message, leave
__getattr__alone). Leaving it with that PR; sorry for the extra round trip.divyanshus2404 commentedon Nov 13, 2026
Noting that #70883 fixed this and was approved, but got auto-closed as stale before a committer merged it. @bujjibabukatta are you planning to reopen it? If not, happy to carry it forward with your commit credited — seems a shame to lose an approved fix.