hussein-awala commented on issue #30356:
URL: https://github.com/apache/airflow/issues/30356#issuecomment-1491032514
Task Instance Details contains the operator arguments, so if you load the
secret in the dag script outside the method execute (which is not recommended
and considered as a bad practice), then you provide it as an argument for the
operator, the operator will process it as a normal argument.
if it's the case, you can use jinja instead and load it in runtime:
```python
import datetime
from airflow import DAG
from airflow.models.baseoperator import BaseOperator
from airflow.models import Variable
class MyOperator(BaseOperator):
template_fields = ("some_arg",)
def __init__(self, some_arg, **kwargs):
super().__init__(**kwargs)
self.some_arg = some_arg
def execute(self, context):
print(self.some_arg)
with DAG(
'secret_masking_test',
schedule_interval=None,
catchup=False,
start_date=datetime.datetime(2018, 1, 1)
) as dag:
bad_task = MyOperator(task_id="bad_task",
some_arg=Variable.get("password"))
good_task = MyOperator(task_id="good_task", some_arg="{{
var.value.password }}")
```
bad_task:

good_task:

and it's loaded just before the method execute, and you can use it inside
the method without any problem.
If your problem is different, please provide a reproducible example.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]