You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bb...@apache.org on 2022/04/14 16:25:56 UTC

[airflow] 01/01: Include message in graph errors

This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch Improve-graph-errors
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 35900e8f4536f03182ba0c5175d5cbe7f23503b5
Author: Brent Bovenzi <br...@gmail.com>
AuthorDate: Thu Apr 14 12:22:47 2022 -0400

    Include message in graph errors
---
 airflow/www/static/js/graph.js | 5 +++--
 airflow/www/views.py           | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/airflow/www/static/js/graph.js b/airflow/www/static/js/graph.js
index ea7fc10cb7..4cac4587a6 100644
--- a/airflow/www/static/js/graph.js
+++ b/airflow/www/static/js/graph.js
@@ -445,8 +445,9 @@ function handleRefresh() {
         setTimeout(() => { $('#loading-dots').hide(); }, 500);
         $('#error').hide();
       },
-    ).fail((_, textStatus, err) => {
-      $('#error_msg').text(`${textStatus}: ${err}`);
+    ).fail((response, textStatus, err) => {
+      const description = (response.responseJSON && response.responseJSON.error) || 'Something went wrong.';
+      $('#error_msg').text(`${textStatus}: ${err} ${description}`);
       $('#error').show();
       setTimeout(() => { $('#loading-dots').hide(); }, 500);
       $('#chart_section').hide(1000);
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 8f2104c90b..237f86d096 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -3376,7 +3376,9 @@ class Airflow(AirflowBaseView):
         if dttm:
             dttm = timezone.parse(dttm)
         else:
-            return "Error: Invalid execution_date"
+            response = jsonify({'error': f"Invalid execution_date {dttm}"})
+            response.status_code = 400
+            return response
 
         with create_session() as session:
             task_instances = {