본문 바로가기

Programming/Tip&Informaion

Airflow connexion error, HTTPStatus error 발생

aws-mwaa-local-runner-2_4-local-runner-1  | Traceback (most recent call last):                                                                                                                                                                     
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/apis/abstract.py", line 222, in add_paths                                                                                     aws-mwaa-local-runner-2_4-local-runner-1  |     self.add_operation(path, method)                                                                                                                                                                   
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/apis/abstract.py", line 175, in add_operation                                                                                 aws-mwaa-local-runner-2_4-local-runner-1  |     operation = make_operation(                                                                                                                                                                        
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/operations/__init__.py", line 16, in make_operation                                                                           aws-mwaa-local-runner-2_4-local-runner-1  |     return spec.operation_cls.from_spec(spec, *args, **kwargs)                                                                                                                                         
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/operations/openapi.py", line 134, in from_spec                                                                                aws-mwaa-local-runner-2_4-local-runner-1  |     return cls(                                                                                                                                                                                        
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/operations/openapi.py", line 81, in __init__                                                                                  aws-mwaa-local-runner-2_4-local-runner-1  |     super().__init__(                                                                                                                                                                                  
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/operations/abstract.py", line 101, in __init__                                                                                
aws-mwaa-local-runner-2_4-local-runner-1  |     self._resolution = resolver.resolve(self)                                                                                                                                                          
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/resolver.py", line 47, in resolve                                                                                             
aws-mwaa-local-runner-2_4-local-runner-1  |     return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)                                                                                                             
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/connexion/resolver.py", line 71, in resolve_function_from_operation_id                                                                  
aws-mwaa-local-runner-2_4-local-runner-1  |     raise ResolverError(msg, sys.exc_info())                                                                                                                                                           
aws-mwaa-local-runner-2_4-local-runner-1  | connexion.exceptions.ResolverError: <ResolverError: Cannot resolve operationId "airflow.api_connexion.endpoints.connection_endpoint.get_connections"! Import error was "cannot import name 'HTTPStatus'
 from 'http' (/usr/local/airflow/plugins/operators/core/http.py)">   

...

aws-mwaa-local-runner-2_4-local-runner-1  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed                                                                                                                         
aws-mwaa-local-runner-2_4-local-runner-1  |   File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow/api_connexion/endpoints/connection_endpoint.py", line 20, in <module>                                                           
aws-mwaa-local-runner-2_4-local-runner-1  |     from http import HTTPStatus                                                                                                                                                                        
aws-mwaa-local-runner-2_4-local-runner-1  | ImportError: cannot import name 'HTTPStatus' from 'http' (/usr/local/airflow/plugins/operators/core/http.py)

airflow에서 mwaa로 이관 중에 connextion library와 http library 문제가 발생했다.

원인을 알 수 없어서 살펴보니 httpOperator를 custom하게 사용한 게 문제인가 했는데, httpOperator를 정의한 파일이 http라서 http 라이브러리를 import를 하지 않고 정의한 파일을 import 파일을 사용하려해서 발생한 문제였다.

 

파일명을 변경하니 해결됐다.