You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2022/12/06 01:41:26 UTC

[superset] branch master updated: chore: return 404 instead of 500 for datasource not found (#22333)

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

hugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f23a9ceac chore: return 404 instead of 500 for datasource not found (#22333)
2f23a9ceac is described below

commit 2f23a9ceac898aabd5b8247ef86dfd4a0487b982
Author: Hugh A. Miles II <hu...@gmail.com>
AuthorDate: Mon Dec 5 20:41:19 2022 -0500

    chore: return 404 instead of 500 for datasource not found (#22333)
---
 superset/charts/data/api.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/superset/charts/data/api.py b/superset/charts/data/api.py
index 773229ad5f..152383e0c6 100644
--- a/superset/charts/data/api.py
+++ b/superset/charts/data/api.py
@@ -41,6 +41,7 @@ from superset.charts.post_processing import apply_post_process
 from superset.charts.schemas import ChartDataQueryContextSchema
 from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
 from superset.connectors.base.models import BaseDatasource
+from superset.dao.exceptions import DatasourceNotFound
 from superset.exceptions import QueryObjectValidationError
 from superset.extensions import event_logger
 from superset.utils.async_query_manager import AsyncQueryTokenException
@@ -141,6 +142,8 @@ class ChartDataRestApi(ChartRestApi):
             query_context = self._create_query_context_from_form(json_body)
             command = ChartDataCommand(query_context)
             command.validate()
+        except DatasourceNotFound as error:
+            return self.response_404()
         except QueryObjectValidationError as error:
             return self.response_400(message=error.message)
         except ValidationError as error:
@@ -229,6 +232,8 @@ class ChartDataRestApi(ChartRestApi):
             query_context = self._create_query_context_from_form(json_body)
             command = ChartDataCommand(query_context)
             command.validate()
+        except DatasourceNotFound as error:
+            return self.response_404()
         except QueryObjectValidationError as error:
             return self.response_400(message=error.message)
         except ValidationError as error: