You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/09/26 08:55:54 UTC
[airflow] branch main updated: Inherit `AirflowNotFound` from
`connextion.NotFound` for better readability (#18523)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7c9aba5 Inherit `AirflowNotFound` from `connextion.NotFound` for better readability (#18523)
7c9aba5 is described below
commit 7c9aba52de954b56e7f53e4bbb5270be80e68c20
Author: Wei-Hsiang (Matt) Wang <ma...@gmail.com>
AuthorDate: Sun Sep 26 16:55:33 2021 +0800
Inherit `AirflowNotFound` from `connextion.NotFound` for better readability (#18523)
---
airflow/api_connexion/endpoints/task_instance_endpoint.py | 9 ++-------
airflow/exceptions.py | 3 ++-
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/airflow/api_connexion/endpoints/task_instance_endpoint.py b/airflow/api_connexion/endpoints/task_instance_endpoint.py
index cfa27ac..4d53ebc 100644
--- a/airflow/api_connexion/endpoints/task_instance_endpoint.py
+++ b/airflow/api_connexion/endpoints/task_instance_endpoint.py
@@ -34,7 +34,6 @@ from airflow.api_connexion.schemas.task_instance_schema import (
task_instance_reference_collection_schema,
task_instance_schema,
)
-from airflow.exceptions import SerializedDagNotFound
from airflow.models import SlaMiss
from airflow.models.dagrun import DagRun as DR
from airflow.models.taskinstance import TaskInstance as TI, clear_task_instances
@@ -276,12 +275,8 @@ def post_set_task_instances_state(dag_id, session):
raise BadRequest(detail=str(err.messages))
error_message = f"Dag ID {dag_id} not found"
- try:
- dag = current_app.dag_bag.get_dag(dag_id)
- if not dag:
- raise NotFound(error_message)
- except SerializedDagNotFound:
- # If DAG is not found in serialized_dag table
+ dag = current_app.dag_bag.get_dag(dag_id)
+ if not dag:
raise NotFound(error_message)
task_id = data['task_id']
diff --git a/airflow/exceptions.py b/airflow/exceptions.py
index a3ce7e2..d998c34 100644
--- a/airflow/exceptions.py
+++ b/airflow/exceptions.py
@@ -23,6 +23,7 @@ import datetime
import warnings
from typing import Any, Dict, List, NamedTuple, Optional
+from airflow.api_connexion.exceptions import NotFound as ApiConnextionNotFound
from airflow.utils.code_utils import prepare_code_snippet
from airflow.utils.platform import is_tty
@@ -42,7 +43,7 @@ class AirflowBadRequest(AirflowException):
status_code = 400
-class AirflowNotFoundException(AirflowException):
+class AirflowNotFoundException(AirflowException, ApiConnextionNotFound):
"""Raise when the requested object/resource is not available in the system"""
status_code = 404