[
https://issues.apache.org/jira/browse/AIRFLOW-3141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16650184#comment-16650184
]
ASF GitHub Bot commented on AIRFLOW-3141:
-----------------------------------------
msumit closed pull request #3984: [AIRFLOW-3141] Handle duration for missing
dag.
URL: https://github.com/apache/incubator-airflow/pull/3984
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 0aef2281e7..f2414b680d 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -1612,6 +1612,10 @@ def duration(self, session=None):
num_runs = request.args.get('num_runs')
num_runs = int(num_runs) if num_runs else default_dag_run
+ if dag is None:
+ flash('DAG "{0}" seems to be missing.'.format(dag_id), "error")
+ return redirect('/admin/')
+
if base_date:
base_date = pendulum.parse(base_date)
else:
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index e6e505c41a..7658c5c3f9 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -1352,6 +1352,10 @@ def duration(self, session=None):
num_runs = request.args.get('num_runs')
num_runs = int(num_runs) if num_runs else default_dag_run
+ if dag is None:
+ flash('DAG "{0}" seems to be missing.'.format(dag_id), "error")
+ return redirect('/')
+
if base_date:
base_date = pendulum.parse(base_date)
else:
diff --git a/tests/core.py b/tests/core.py
index 918e9b4d49..91062f6e58 100644
--- a/tests/core.py
+++ b/tests/core.py
@@ -1877,6 +1877,10 @@ def test_dag_views(self):
response = self.app.get(
'/admin/airflow/duration?days=30&dag_id=example_bash_operator')
self.assertIn("example_bash_operator", response.data.decode('utf-8'))
+ response = self.app.get(
+ '/admin/airflow/duration?days=30&dag_id=missing_dag',
+ follow_redirects=True)
+ self.assertIn("seems to be missing", response.data.decode('utf-8'))
response = self.app.get(
'/admin/airflow/tries?days=30&dag_id=example_bash_operator')
self.assertIn("example_bash_operator", response.data.decode('utf-8'))
diff --git a/tests/www_rbac/test_views.py b/tests/www_rbac/test_views.py
index a952b9874c..e79cfb6db8 100644
--- a/tests/www_rbac/test_views.py
+++ b/tests/www_rbac/test_views.py
@@ -381,6 +381,11 @@ def test_duration(self):
resp = self.client.get(url, follow_redirects=True)
self.check_content_in_response('example_bash_operator', resp)
+ def test_duration_missing(self):
+ url = 'duration?days=30&dag_id=missing_dag'
+ resp = self.client.get(url, follow_redirects=True)
+ self.check_content_in_response('seems to be missing', resp)
+
def test_tries(self):
url = 'tries?days=30&dag_id=example_bash_operator'
resp = self.client.get(url, follow_redirects=True)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Fix 500 on duration view when dag doesn't exist
> -----------------------------------------------
>
> Key: AIRFLOW-3141
> URL: https://issues.apache.org/jira/browse/AIRFLOW-3141
> Project: Apache Airflow
> Issue Type: Bug
> Reporter: Josh Carp
> Assignee: Josh Carp
> Priority: Trivial
>
> Loading the duration view for a dag that doesn't exist throws a 500. Based on
> the behavior of other dag views, this should redirect to the admin view and
> flash an error message instead.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)