sha174n commented on code in PR #39303:
URL: https://github.com/apache/superset/pull/39303#discussion_r3294550461
##########
superset/views/sql_lab/views.py:
##########
@@ -268,11 +282,24 @@ def delete(self, table_schema_id: int) -> FlaskResponse:
@has_access_api
@expose("/<int:table_schema_id>/expanded", methods=("POST",))
def expanded(self, table_schema_id: int) -> FlaskResponse:
- payload = json.loads(request.form["expanded"])
- (
- db.session.query(TableSchema)
- .filter_by(id=table_schema_id)
- .update({"expanded": payload})
- )
- response = json.dumps({"id": table_schema_id, "expanded": payload})
- return json_success(response)
+ try:
+ tab_state_id = (
+ db.session.query(TableSchema.tab_state_id)
+ .filter_by(id=table_schema_id)
+ .scalar()
+ )
+ if tab_state_id is None:
+ return json_error_response(__("Not found"), status=404)
+ owner_id = _get_owner_id(tab_state_id)
+ if owner_id is None or owner_id != get_user_id():
+ return json_error_response(__("Forbidden"), status=403)
+ payload = json.loads(request.form["expanded"])
+ db.session.query(TableSchema).filter_by(id=table_schema_id).update(
+ {"expanded": payload}
+ )
+ db.session.commit()
+ response = json.dumps({"id": table_schema_id, "expanded": payload})
+ return json_success(response)
+ except Exception as ex: # pylint: disable=broad-except
Review Comment:
Declining: `except (ValueError, Exception)` is a no-op since `Exception`
already covers `ValueError`. The broad-except with the pylint disable is the
existing pattern in this file for top-level request handlers — it converts
unexpected errors into structured JSON responses instead of 500s. Narrowing the
catch is out of scope for this security-focused PR.
--
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]