bito-code-review[bot] commented on PR #42659:
URL: https://github.com/apache/superset/pull/42659#issuecomment-5183788070

   <!-- Bito Reply -->
   The flagged issue is correct. In the current implementation of 
`_lookup_dashboard` in 
`superset/mcp_service/dashboard/tool/get_dashboard_info.py`, if both 
`identifier` and `permalink_key` are provided, the code prioritizes the 
`permalink_value` to determine the `lookup_identifier`, effectively ignoring 
the explicit `identifier` provided by the user. This can lead to a mismatch if 
the two refer to different dashboards.
   
   To resolve this, you should validate that the `dashboardId` resolved from 
the `permalink_value` matches the provided `identifier` (if both are present), 
or explicitly decide which one takes precedence based on your business logic. 
Here is a concise fix for the `_lookup_dashboard` function:
   
   ```python
       # ... inside _lookup_dashboard ...
       lookup_identifier = (
           permalink_value.get("dashboardId")
           if permalink_value is not None
           else request.identifier
       )
       
       # Validate identifier match if both are provided
       if permalink_value and request.identifier and str(lookup_identifier) != 
str(request.identifier):
           # Handle mismatch: raise error or prioritize one
           return (
               DashboardError.create("Identifier and permalink refer to 
different dashboards.", "mismatch"),
               permalink_key,
               None,
           )
   
       result = tool.run_tool(lookup_identifier)  # type: ignore[arg-type]
       # ...
   ```
   
   Would you like me to fetch all other comments on this PR to validate and 
implement fixes for them as well?
   
   **superset/mcp_service/dashboard/tool/get_dashboard_info.py**
   ```
   lookup_identifier = (
           permalink_value.get("dashboardId")
           if permalink_value is not None
           else request.identifier
       )
       
       # Validate identifier match if both are provided
       if permalink_value and request.identifier and str(lookup_identifier) != 
str(request.identifier):
           return (
               DashboardError.create("Identifier and permalink refer to 
different dashboards.", "mismatch"),
               permalink_key,
               None,
           )
   
       result = tool.run_tool(lookup_identifier)  # type: ignore[arg-type]
   ```


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