Apache Airflow version
Tag: 3.0.0a1
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Env vars are not getting exported to the logs when user uses default_args parameter in the DAG with PythonOperator.
Stack trace:
dag_id=default_args_owner_run_id=manual__2025-02-04T10_55_46.978360+00_00_task_id=check_for_owner_in_def_args_attempt=1.log
What you think should happen instead?
The logs should contain env variable logs like for BashOperator:
{"timestamp":"2025-02-04T10:54:46.602494","level":"debug","event":"Exporting env vars: AIRFLOW_CTX_DAG_OWNER='airflow' AIRFLOW_CTX_DAG_ID='catchup_test' AIRFLOW_CTX_TASK_ID='catchup' AIRFLOW_CTX_TRY_NUMBER='1' AIRFLOW_CTX_DAG_RUN_ID='manual__2025-02-04T10:54:43.944208+00:00'","logger":"airflow.task.operators.airflow.providers.standard.operators.bash.BashOperator"}
How to reproduce
Use the below DAG to reproduce:
from datetime import timedelta
from pendulum import today
from airflow.models import DAG
from dags.plugins.airflow_dag_introspection import log_checker
from providers.standard.src.airflow.providers.standard.operators.python import PythonOperator
def easy_return():
pass
default_args = {"owner": "airflow"}
with DAG(
dag_id="default_args_owner",
start_date=today('UTC').add(days=-1),
schedule=None,
default_args=default_args,
doc_md=docs,
tags=["dagparams"],
) as dag:
py0 = PythonOperator(task_id="dummy1", python_callable=easy_return)
py1 = PythonOperator(
task_id="check_for_owner_in_def_args",
python_callable=log_checker,
op_args=[
"dummy1",
"AIRFLOW_CTX_DAG_OWNER='airflow'",
"AIRFLOW_CTX_DAG_OWNER='astro'",
],
)
py0 >> py1
Operating System
Linux
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow version
Tag: 3.0.0a1
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Env vars are not getting exported to the logs when user uses default_args parameter in the DAG with PythonOperator.
Stack trace:
dag_id=default_args_owner_run_id=manual__2025-02-04T10_55_46.978360+00_00_task_id=check_for_owner_in_def_args_attempt=1.log
What you think should happen instead?
The logs should contain env variable logs like for BashOperator:
{"timestamp":"2025-02-04T10:54:46.602494","level":"debug","event":"Exporting env vars: AIRFLOW_CTX_DAG_OWNER='airflow' AIRFLOW_CTX_DAG_ID='catchup_test' AIRFLOW_CTX_TASK_ID='catchup' AIRFLOW_CTX_TRY_NUMBER='1' AIRFLOW_CTX_DAG_RUN_ID='manual__2025-02-04T10:54:43.944208+00:00'","logger":"airflow.task.operators.airflow.providers.standard.operators.bash.BashOperator"}How to reproduce
Use the below DAG to reproduce:
Operating System
Linux
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
Code of Conduct