From df0668eda5f3329f0d6da68f3585ab613e55e4db Mon Sep 17 00:00:00 2001 From: Cezar Date: Sun, 14 Jun 2026 02:53:08 +0300 Subject: [PATCH] feat(api): return uuid in POST response for dataset, chart, and dashboard (#37806) Co-authored-by: Cursor --- superset/charts/api.py | 2 +- superset/dashboards/api.py | 2 +- superset/datasets/api.py | 8 +++++++- tests/integration_tests/charts/api_tests.py | 3 +++ tests/integration_tests/dashboards/api_tests.py | 3 +++ tests/integration_tests/datasets/api_tests.py | 3 +++ 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/superset/charts/api.py b/superset/charts/api.py index 2a37aca374d..86b8f036601 100644 --- a/superset/charts/api.py +++ b/superset/charts/api.py @@ -365,7 +365,7 @@ class ChartRestApi(BaseSupersetModelRestApi): return self.response_400(message=error.messages) try: new_model = CreateChartCommand(item).run() - return self.response(201, id=new_model.id, result=item) + return self.response(201, id=new_model.id, result=item, uuid=new_model.uuid) except DashboardsForbiddenError as ex: return self.response(ex.status, message=ex.message) except ChartInvalidError as ex: diff --git a/superset/dashboards/api.py b/superset/dashboards/api.py index 666ca339475..52fc7805788 100644 --- a/superset/dashboards/api.py +++ b/superset/dashboards/api.py @@ -754,7 +754,7 @@ class DashboardRestApi(CustomTagsOptimizationMixin, BaseSupersetModelRestApi): return self.response_400(message=error.messages) try: new_model = CreateDashboardCommand(item).run() - return self.response(201, id=new_model.id, result=item) + return self.response(201, id=new_model.id, result=item, uuid=new_model.uuid) except DashboardInvalidError as ex: return self.response_422(message=ex.normalized_messages()) except DashboardCreateFailedError as ex: diff --git a/superset/datasets/api.py b/superset/datasets/api.py index 73ae2ee4274..ab7d254f2bc 100644 --- a/superset/datasets/api.py +++ b/superset/datasets/api.py @@ -357,7 +357,13 @@ class DatasetRestApi(BaseSupersetModelRestApi): try: new_model = CreateDatasetCommand(item).run() - return self.response(201, id=new_model.id, result=item, data=new_model.data) + return self.response( + 201, + id=new_model.id, + result=item, + data=new_model.data, + uuid=new_model.uuid, + ) except DatasetInvalidError as ex: return self.response_422(message=ex.normalized_messages()) except DatasetCreateFailedError as ex: diff --git a/tests/integration_tests/charts/api_tests.py b/tests/integration_tests/charts/api_tests.py index 17c369c86db..b61ac963d5a 100644 --- a/tests/integration_tests/charts/api_tests.py +++ b/tests/integration_tests/charts/api_tests.py @@ -556,6 +556,9 @@ class TestChartApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCase): assert rv.status_code == 201 data = json.loads(rv.data.decode("utf-8")) model = db.session.query(Slice).get(data.get("id")) + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) db.session.delete(model) db.session.commit() diff --git a/tests/integration_tests/dashboards/api_tests.py b/tests/integration_tests/dashboards/api_tests.py index ef5104b9184..70ef455e6de 100644 --- a/tests/integration_tests/dashboards/api_tests.py +++ b/tests/integration_tests/dashboards/api_tests.py @@ -1746,6 +1746,9 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas assert rv.status_code == 201 data = json.loads(rv.data.decode("utf-8")) model = db.session.query(Dashboard).get(data.get("id")) + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) db.session.delete(model) db.session.commit() diff --git a/tests/integration_tests/datasets/api_tests.py b/tests/integration_tests/datasets/api_tests.py index ba253573e2e..9156cd78e0e 100644 --- a/tests/integration_tests/datasets/api_tests.py +++ b/tests/integration_tests/datasets/api_tests.py @@ -725,6 +725,9 @@ class TestDatasetApi(SupersetTestCase): assert model.database_id == table_data["database"] # normalize_columns should default to False assert model.normalize_columns is False + # uuid should be returned in the response + assert "uuid" in data + assert str(model.uuid) == str(data["uuid"]) # Assert that columns were created columns = (