theaadya commented on PR #34966:
URL: https://github.com/apache/airflow/pull/34966#issuecomment-1767683896

   I created a set of test cases to evaluate the functionality of the 
`execute_failed` function. In the unit test for accessing the `else` part of 
the function, `KeyError` for 'exception' occurred. I think this was one of the 
issues that @Taragolis was referring to. Should the function raise an 
AirflowExcpetion instead, as @Lee-W suggested? 
   
   ```
   ========================================================= FAILURES 
==========================================================
   ___________________________ 
TestEksCreateClusterOperator.test_execute_failed_event_status_deleted 
___________________________
   
   self = 
<tests.providers.amazon.aws.operators.test_eks.TestEksCreateClusterOperator 
object at 0x7f766bf272e0>
   
       def test_execute_failed_event_status_deleted(self):
           operator = EksCreateClusterOperator(
               task_id=TASK_ID,
               **self.create_cluster_params,
               compute=None,
               wait_for_completion=False,
               deferrable=True,
           )
           event = {"status": "deleted"}
   >       operator.execute_failed(None, event)
   
   tests/providers/amazon/aws/operators/test_eks.py:402:
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
   
   self = <Task(EksCreateClusterOperator): test-eks-operator>, context = None, 
event = {'status': 'deleted'}
   
       def execute_failed(self, context: Context, event: dict[str, Any] | None 
= None) -> None:
           if event is None or event["status"] != "deleted":
               self.log.info("Trigger error: event is %s", event)
               raise AirflowException(f"Trigger error: event is {event}")
           else:
               self.log.info("Cluster deleted")
   >           raise event["exception"]
   E           KeyError: 'exception'
   
   airflow/providers/amazon/aws/operators/eks.py:405: KeyError
   ```
   
   Furthermore, please provide guidance if there are some errors or if I should 
approach the issue differently.


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