bito-code-review[bot] commented on code in PR #40130:
URL: https://github.com/apache/superset/pull/40130#discussion_r3398716268
##########
superset/datasets/api.py:
##########
@@ -908,6 +930,64 @@ def bulk_delete(self, **kwargs: Any) -> Response:
except DatasetDeleteFailedError as ex:
return self.response_422(message=str(ex))
+ @expose("/<uuid>/restore", methods=("POST",))
+ @protect()
+ @safe
+ @statsd_metrics
+ @event_logger.log_this_with_context(
+ action=lambda self, *args, **kwargs:
f"{self.__class__.__name__}.restore",
+ log_to_statsd=False,
+ )
+ def restore(self, uuid: str) -> Response:
+ """Restore a soft-deleted dataset.
+ ---
+ post:
+ summary: Restore a soft-deleted dataset
+ parameters:
+ - in: path
+ schema:
+ type: string
+ format: uuid
+ name: uuid
+ responses:
+ 200:
+ description: Dataset restored
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ 401:
+ $ref: '#/components/responses/401'
+ 403:
+ $ref: '#/components/responses/403'
+ 404:
+ $ref: '#/components/responses/404'
+ 422:
+ $ref: '#/components/responses/422'
+ 500:
+ $ref: '#/components/responses/500'
+ """
+ try:
+ RestoreDatasetCommand(uuid).run()
+ return self.response(200, message="OK")
+ except DatasetNotFoundError:
+ return self.response_404()
+ except DatasetForbiddenError:
+ return self.response_403()
+ except DatasetLogicalDuplicateError as ex:
+ return self.response_422(message=str(ex))
+ except DatasetRestoreFailedError as ex:
+ logger.error(
+ "Error restoring model %s: %s",
+ self.__class__.__name__,
+ str(ex),
+ exc_info=True,
+ )
+ return self.response_422(message=str(ex))
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing integration tests for error paths</b></div>
<div id="fix">
The `restore` endpoint has no integration test for
`DatasetLogicalDuplicateError` → 422. The unit test
`test_restore_dataset_logical_duplicate_raises` covers the command, but not the
API contract. Similarly, the 404 (non-existent UUID) and 403 (non-owner) paths
lack integration coverage. Per BITO.md rule [11730], new features should
include tests for error scenarios.
</div>
</div>
<small><i>Code Review Run #0a8946</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/translations/zh_TW/LC_MESSAGES/messages.po:
##########
@@ -4640,6 +4640,9 @@ msgstr "無法創建數據集。"
msgid "Dataset could not be duplicated."
msgstr "數據集無法複製。"
+msgid "Dataset could not be restored."
+msgstr ""
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing zh_TW translation</b></div>
<div id="fix">
The msgstr field is empty. Users in the zh_TW locale will see untranslated
English text "Dataset could not be restored." instead of a proper Chinese
translation. Compare with adjacent entries which follow the pattern
"無法/無法+[verb]+數據集" (e.g., "無法創建數據集", "無法更新數據集"). Apply rule [6516]: provide
complete translations for all user-facing text.
</div>
</div>
<small><i>Code Review Run #0a8946</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]