codeant-ai-for-open-source[bot] commented on code in PR #42659:
URL: https://github.com/apache/superset/pull/42659#discussion_r3715648488
##########
superset/mcp_service/dashboard/tool/get_dashboard_info.py:
##########
@@ -96,13 +96,57 @@ def _get_permalink_state(permalink_key: str) ->
DashboardPermalinkValue | None:
Returns the permalink value containing dashboardId and state if found,
None otherwise.
"""
- from superset.commands.dashboard.permalink.get import
GetDashboardPermalinkCommand
+ resolved = get_dashboard_permalink(permalink_key)
+ return resolved[1] if resolved else None
+
+
+def _lookup_dashboard(
+ tool: ModelGetInfoCore,
+ request: GetDashboardInfoRequest,
+) -> tuple[DashboardInfo | DashboardError, str | None, DashboardPermalinkValue
| None]:
+ """Resolve an ordinary identifier or dashboard permalink, then run
lookup."""
+ permalink_key = request.permalink_key
+ if isinstance(request.identifier, str):
+ extracted_key = extract_dashboard_permalink_key(request.identifier)
+ if extracted_key != request.identifier:
+ permalink_key = extracted_key
+ permalink_value = _get_permalink_state(permalink_key) if permalink_key
else None
+ if permalink_key and permalink_value is None:
+ return (
+ DashboardError.create(
+ "Dashboard permalink could not be resolved. It may be invalid
or "
+ "expired; ask for a fresh shared dashboard link.",
+ "permalink_not_found",
+ ),
+ permalink_key,
+ None,
+ )
+ if permalink_key:
+ permalink_key = extract_dashboard_permalink_key(permalink_key)
- try:
- return GetDashboardPermalinkCommand(permalink_key).run()
- except DashboardPermalinkGetFailedError as e:
- logger.warning("Failed to retrieve permalink state: %s", e)
- return None
+ lookup_identifier = (
+ permalink_value.get("dashboardId")
+ if permalink_value is not None
+ else request.identifier
+ )
+ result = tool.run_tool(lookup_identifier) # type: ignore[arg-type]
Review Comment:
**Suggestion:** When both fields are supplied, resolving `permalink_key`
takes precedence over the explicit `identifier`, so `lookup_identifier` is
taken from the permalink's `dashboardId` and the requested dashboard is
ignored. A mismatched identifier/permalink pair can therefore return metadata
for a different dashboard; validate that both identifiers refer to the same
dashboard or preserve the explicit identifier for the lookup. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Combined identifier requests can return unexpected dashboards.
- ⚠️ MCP callers may associate filters with the wrong dashboard.
- ⚠️ Existing tests confirm both fields are supported together.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8ad3785125cf4f95a4d5faf50405fc79&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8ad3785125cf4f95a4d5faf50405fc79&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/dashboard/tool/get_dashboard_info.py
**Line:** 108:132
**Comment:**
*Api Mismatch: When both fields are supplied, resolving `permalink_key`
takes precedence over the explicit `identifier`, so `lookup_identifier` is
taken from the permalink's `dashboardId` and the requested dashboard is
ignored. A mismatched identifier/permalink pair can therefore return metadata
for a different dashboard; validate that both identifiers refer to the same
dashboard or preserve the explicit identifier for the lookup.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42659&comment_hash=4f7137e7bd2f6d82ac4f321572857499189d3ab0d2cd9e8f115a75f33dad47a1&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42659&comment_hash=4f7137e7bd2f6d82ac4f321572857499189d3ab0d2cd9e8f115a75f33dad47a1&reaction=dislike'>👎</a>
--
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]