bito-code-review[bot] commented on code in PR #44080:
URL: https://github.com/apache/superset/pull/44080#discussion_r4133392436
##########
superset/views/datasource/views.py:
##########
@@ -121,25 +256,28 @@ def save(self) -> FlaskResponse:
except SupersetSecurityException as ex:
raise DatasetForbiddenError() from ex
- if database_id != orm_datasource.database_id:
- new_database = DatasetDAO.get_database_by_id(database_id)
- if new_database is None:
- return json_error_response(_("Database not found."),
status=422)
- try:
- security_manager.raise_for_access(
- database=new_database,
- # Check access against the table/schema/catalog the
- # request is repointing to, not the dataset's current
- # values -- update_from_object (below) applies whatever
- # table_name/schema/catalog the request supplies.
- table=Table(
- datasource_dict.get("table_name",
orm_datasource.table_name),
- datasource_dict.get("schema", orm_datasource.schema),
- datasource_dict.get("catalog", orm_datasource.catalog),
- ),
- )
- except SupersetSecurityException as ex:
- raise DatasetForbiddenError() from ex
+ database_changed = database_id != orm_datasource.database_id
+ try:
+ requested_sql, requested_table = _requested_target(datasource_dict)
+ except ValueError as ex:
+ return json_error_response(
+ _(
+ "Dataset schema is invalid, caused by: %(error)s",
+ error=f"`{ex}` must be a string",
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Misleading untranslated error</b></div>
<div id="fix">
`_requested_target` raises `ValueError(field)` naming the field
(views.py:162), so `{ex}` renders e.g. `sql` — the message reads 'caused by:
`sql` must be a string', misattributing a payload type error to the dataset
schema. The f-string is also interpolated after `_()`, leaving 'must be a
string' untranslated (BITO 6516). Make the whole sentence the msgid with a
`%(field)s` placeholder.
</div>
</div>
<small><i>Code Review Run #363ea4</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]