atul-astronomer opened a new issue, #46418:
URL: https://github.com/apache/airflow/issues/46418

   ### Apache Airflow version
   
   main (development)
   
   ### 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.
   
   **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](https://github.com/user-attachments/files/18656321/dag_id.default_args_owner_run_id.manual__2025-02-04T10_55_46.978360%2B00_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 in 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:
   
   ```python
   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?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]

Reply via email to