feat(api): return uuid in POST response for dataset, chart, and dashboard#37806
feat(api): return uuid in POST response for dataset, chart, and dashboard#37806cezudas wants to merge 1 commit intoapache:masterfrom
Conversation
…oard The auto-generated uuid was missing from the POST creation response for datasets, charts, and dashboards, making it impossible for API consumers to reference newly created resources by UUID without a subsequent GET request. The database endpoint already returns uuid in its POST response (via `item["uuid"] = new_model.uuid`). This change brings the other three resource types in line with that precedent by adding `uuid=new_model.uuid` to the `self.response()` call in each endpoint. This is needed for programmatic workflows such as cross-environment dashboard imports that use `dataset_mapping` and `database_mapping` parameters, which require UUIDs to map resources across instances. Closes apache#15456 Co-authored-by: Cursor <cursoragent@cursor.com>
|
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR). Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #ac2c4fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
Pull request overview
This PR updates Superset’s REST create endpoints so API consumers receive the server-generated UUID immediately after creating datasets, charts, and dashboards—removing the need for a follow-up GET to obtain the UUID.
Changes:
- Include
uuidin POST (201) responses for dataset, chart, and dashboard create endpoints. - Add integration test assertions verifying
uuidis present and matches the persisted model UUID.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
superset/datasets/api.py |
Adds uuid to the dataset POST response payload. |
superset/charts/api.py |
Adds uuid to the chart POST response payload. |
superset/dashboards/api.py |
Adds uuid to the dashboard POST response payload. |
tests/integration_tests/datasets/api_tests.py |
Verifies dataset POST response includes uuid. |
tests/integration_tests/charts/api_tests.py |
Verifies chart POST response includes uuid. |
tests/integration_tests/dashboards/api_tests.py |
Verifies dashboard POST response includes uuid. |
| 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) |
There was a problem hiding this comment.
The POST endpoint now includes a top-level uuid in the 201 response, but the OpenAPI docstring for this endpoint still documents only id and result under responses: 201. Please update the response schema docs to include the uuid field so generated API docs match the actual payload.
| 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) |
There was a problem hiding this comment.
The POST endpoint now returns a top-level uuid in the 201 response, but the OpenAPI docstring for this route still lists only id and result in the 201 schema. Update the documented response properties to include uuid to keep the OpenAPI spec accurate.
| 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) |
There was a problem hiding this comment.
This POST now includes uuid in the 201 response payload, but the OpenAPI docstring still only documents id and result under responses: 201. Please add uuid to the documented response schema so the generated API docs match behavior.
| 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) |
There was a problem hiding this comment.
This self.response(...) call exceeds typical line-length/Black formatting used in the repo. Reformat this call onto multiple lines (with trailing commas) so it stays Black-compliant and avoids CI formatting failures.
| return self.response(201, id=new_model.id, result=item, data=new_model.data, uuid=new_model.uuid) | |
| return self.response( | |
| 201, | |
| id=new_model.id, | |
| result=item, | |
| data=new_model.data, | |
| uuid=new_model.uuid, | |
| ) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #37806 +/- ##
===========================================
+ Coverage 0 66.22% +66.22%
===========================================
Files 0 647 +647
Lines 0 49579 +49579
Branches 0 5577 +5577
===========================================
+ Hits 0 32833 +32833
- Misses 0 15443 +15443
- Partials 0 1303 +1303
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
SUMMARY
The auto-generated uuid was missing from the POST creation response for datasets, charts, and dashboards, making it impossible for API consumers to reference newly created resources by UUID without a subsequent GET request.
The database endpoint already returns uuid in its POST response (via
item["uuid"] = new_model.uuid). This change brings the other three resource types in line with that precedent by addinguuid=new_model.uuidto theself.response()call in each endpoint.This is needed for programmatic workflows such as cross-environment dashboard imports that use
dataset_mappinganddatabase_mappingparameters, which require UUIDs to map resources across instances.Closes #15456 (Issue was already marked as closed due to inactivity)
TESTING INSTRUCTIONS
For each of these following endpoints ensure uuid field exist in the response:
ADDITIONAL INFORMATION