mik-laj commented on a change in pull request #9330: URL: https://github.com/apache/airflow/pull/9330#discussion_r440928429
########## File path: airflow/api_connexion/endpoints/task_endpoint.py ########## @@ -14,20 +14,42 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +from airflow import DAG +from airflow.api_connexion.exceptions import NotFound +from airflow.api_connexion.schemas.task_schema import TaskCollection, task_collection_schema, task_schema +from airflow.configuration import conf +from airflow.exceptions import TaskNotFound +from airflow.models import DagBag -# TODO(mik-laj): We have to implement it. -# Do you want to help? Please look at: https://github.com/apache/airflow/issues/8138 - -def get_task(): +def get_task(dag_id, task_id): """ Get simplified representation of a task. """ - raise NotImplementedError("Not implemented yet.") + dag_bag = DagBag( + store_serialized_dags=conf.getboolean('core', 'store_serialized_dags'), + ) + dag: DAG = dag_bag.get_dag(dag_id) + if not dag: + raise NotFound("DAG not found") Review comment: We should raise [NotFound](https://github.com/apache/airflow/blob/7c12a9d4e0b6c1e01fee6ab227a6e25b5aa5b157/airflow/api_connexion/exceptions.py#L20) exception. This class is correctly handled by connection and generates the response in the valid format. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
