Skip to content

Commit

Permalink
fix: Added message flash when chart with missing dataset is accessed. (
Browse files Browse the repository at this point in the history
  • Loading branch information
kkucharc authored Jan 19, 2021
1 parent 9e47ee2 commit ad63823
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,14 @@ def explore( # pylint: disable=too-many-locals,too-many-return-statements
datasource_id, datasource_type = get_datasource_info(
datasource_id, datasource_type, form_data
)
except SupersetException:
except SupersetException as ex:
flash(
_(
"Error occurred when opening the chart: %(error)s",
error=utils.error_msg_from_exception(ex),
),
"danger",
)
return redirect(error_redirect)

datasource = ConnectorRegistry.get_datasource(
Expand Down
2 changes: 1 addition & 1 deletion superset/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def get_datasource_info(

if not datasource_id:
raise SupersetException(
"The datasource associated with this chart no longer exists"
"The dataset associated with this chart no longer exists"
)

datasource_id = int(datasource_id)
Expand Down
2 changes: 1 addition & 1 deletion tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def test_slice_payload_no_datasource(self):

self.assertEqual(
data["errors"][0]["message"],
"The datasource associated with this chart no longer exists",
"The dataset associated with this chart no longer exists",
)

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
Expand Down
2 changes: 1 addition & 1 deletion tests/tasks/async_queries_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ def test_load_explore_json_into_cache_error(self, mock_update_job):
with pytest.raises(SupersetException):
load_explore_json_into_cache(job_metadata, form_data)

errors = ["The datasource associated with this chart no longer exists"]
errors = ["The dataset associated with this chart no longer exists"]
mock_update_job.assert_called_with(job_metadata, "error", errors=errors)

0 comments on commit ad63823

Please sign in to comment.