bito-code-review[bot] commented on code in PR #37183:
URL: https://github.com/apache/superset/pull/37183#discussion_r2774475207
##########
superset/mcp_service/dashboard/tool/get_dashboard_info.py:
##########
@@ -71,14 +110,57 @@ async def get_dashboard_info(
result = tool.run_tool(request.identifier)
if isinstance(result, DashboardInfo):
+ # If permalink_key is provided, retrieve filter state
+ if request.permalink_key:
+ await ctx.info(
+ "Retrieving filter state from permalink: permalink_key=%s"
+ % (request.permalink_key,)
+ )
+ permalink_value = _get_permalink_state(request.permalink_key)
+
+ if permalink_value:
+ # Verify the permalink belongs to the requested dashboard
+ permalink_dashboard_id = permalink_value.get("dashboardId")
+ if (
+ isinstance(permalink_dashboard_id, int)
+ and permalink_dashboard_id != result.id
+ ):
+ await ctx.warning(
+ "permalink_key dashboardId (%s) does not match "
+ "requested dashboard id (%s); ignoring permalink "
+ "filter state." % (permalink_dashboard_id,
result.id)
+ )
Review Comment:
<!-- Bito Reply -->
Yes, the suggestion is valid — it correctly addresses the type mismatch by
converting the permalink's string `dashboardId` to an integer for comparison
with `result.id`, including fallback handling for non-numeric values to prevent
errors.
**superset/mcp_service/dashboard/tool/get_dashboard_info.py**
```
# Verify the permalink belongs to the requested dashboard
# dashboardId in permalink is stored as str, result.id
is int
permalink_dashboard_id =
permalink_value.get("dashboardId")
try:
permalink_dashboard_id_int = (
int(permalink_dashboard_id)
if permalink_dashboard_id
else None
)
except (ValueError, TypeError):
permalink_dashboard_id_int = None
if (
permalink_dashboard_id_int is not None
and permalink_dashboard_id_int != result.id
):
await ctx.warning(
"permalink_key dashboardId (%s) does not match "
"requested dashboard id (%s); ignoring permalink
"
"filter state." % (permalink_dashboard_id,
result.id)
)
```
--
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]