vikramcse opened a new issue #17715:
URL: https://github.com/apache/airflow/issues/17715


   **Apache Airflow version**:
   
   Airflow 2.1.2
   Database: MySQL 8.0
   
   **OS**: 
   NAME="Ubuntu"
   VERSION="18.04.4 LTS (Bionic Beaver)"
   
   **Deployment**:
   Docker-compose 
   
   **What happened**:
   I am getting errors randomly on airflow version, where conf is None in the 
dag_context
   
   ```python
   def trigger_event_creation_flow(**kwargs):
       event_ids = []
       print("Creating event entry..")
   
       dag_context = get_current_context()
       event_payload = dag_context["dag_run"].conf
       print(f'Payload recd is : {event_payload} and type is 
{type(event_payload)}')
   ```
   
   ```
   [2021-08-18 22:00:11,763] {taskinstance.py:1302} INFO - Exporting the 
following env vars:
   AIRFLOW_CTX_DAG_OWNER=airflow
   AIRFLOW_CTX_DAG_ID=trigger_alert_event
   AIRFLOW_CTX_TASK_ID=trigger_event_creation_flow
   AIRFLOW_CTX_EXECUTION_DATE=2021-08-18T22:00:03.528496+00:00
   [2021-08-18 22:00:11,764] {logging_mixin.py:104} INFO - Creating event 
entry..
   [2021-08-18 22:00:11,764] {taskinstance.py:1501} ERROR - Task failed with 
exception
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py",
 line 1157, in _run_raw_task
       self._prepare_and_execute_task_with_callbacks(context, task)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py",
 line 1331, in _prepare_and_execute_task_with_callbacks
       result = self._execute_task(context, task_copy)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py",
 line 1361, in _execute_task
       result = task_copy.execute(context=context)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/operators/python.py", 
line 198, in execute
       condition = super().execute(context)
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/operators/python.py", 
line 150, in execute
       return_value = self.execute_callable()
     File 
"/home/airflow/.local/lib/python3.6/site-packages/airflow/operators/python.py", 
line 161, in execute_callable
       return self.python_callable(*self.op_args, **self.op_kwargs)
     File "/opt/airflow/dags/trigger_alert_event_dag.py", line 26, in 
trigger_event_creation_flow
       event_payload = dag_context["dag_run"].conf
   AttributeError: 'NoneType' object has no attribute 'conf'
   ```
   
   Added below sentry issue
   
![image](https://user-images.githubusercontent.com/1611331/130047539-29cc2c1c-808f-4190-924f-6e038a04c10e.png)
   
   for that run_id I can see that the conf is present in database
   
![image](https://user-images.githubusercontent.com/1611331/130048093-a535ff00-5b34-49dd-b8c6-f7a7f259a531.png)
   
   **What you expected to happen**:
   `conf` key should non be None in get_current_context()
   
   **How to reproduce it**:
   The issue is getting randomly, not able to reproduce every time
   
   **Are you willing to submit a PR?**
   YES
   


-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to