tien238lnd commented on code in PR #44338:
URL: https://github.com/apache/superset/pull/44338#discussion_r4059766108


##########
superset/mcp_service/chart/tool/get_chart_info.py:
##########
@@ -86,6 +91,125 @@ def _build_unsaved_chart_info(form_data_key: str) -> 
ChartInfo | ChartError:
     )
 
 
+def _get_explore_permalink(
+    permalink_key: str,
+) -> ExplorePermalinkValue | ChartError:
+    """Read an Explore permalink, enforcing the same access checks as Explore.
+
+    ``GetExplorePermalinkCommand`` checks access to the permalink's datasource
+    and, when it references a saved chart, to that chart.
+    """
+    from superset.commands.explore.permalink.get import 
GetExplorePermalinkCommand
+
+    try:
+        value = GetExplorePermalinkCommand(permalink_key).run()
+    except (ForbiddenError, SupersetSecurityException):
+        # Tables raise ForbiddenError subclasses; SQL Lab queries go through
+        # security_manager.raise_for_access, which raises
+        # SupersetSecurityException.
+        return ChartError(
+            error="You do not have access to the chart or dataset in this 
permalink.",
+            error_type="PermalinkAccessDenied",
+        )
+    except SupersetTemplateException as ex:

Review Comment:
   Done in 7fdc69ed64. `SupersetParseError` is now handled together with 
`SupersetTemplateException` and returns `InvalidPermalink`. The message says 
the query's SQL "could not be rendered or parsed" and does not quote it, since 
the parser's message carries a token from the SQL (`near 'WHERE'` in your 
repro). `test_permalink_query_with_unparsable_sql` is the twin you suggested; 
it fails on the previous commit and passes now.
   



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