bito-code-review[bot] commented on code in PR #44080:
URL: https://github.com/apache/superset/pull/44080#discussion_r4133863895


##########
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:
   <!-- Bito Reply -->
   The suggestion to use a `%(field)s` placeholder in the error message is 
appropriate. It correctly addresses the issue of misattributing a payload type 
error to the dataset schema and ensures the entire error message is 
translatable, which improves both the accuracy and maintainability of the code.
   
   **superset/views/datasource/views.py**
   ```
   except ValueError as ex:
               return json_error_response(
                   _(
                       "Dataset schema is invalid, caused by: %(error)s",
                       error=f"`{ex}` must be a string",
   ```



-- 
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]

Reply via email to