aminghadersohi opened a new pull request, #43482:
URL: https://github.com/apache/superset/pull/43482

   ### SUMMARY
   
   Dashboard lookup tools can resolve shared `/dashboard/p/<key>/` links and 
bare permalink keys, returning the dashboard identifier together with the 
permalink's active-tab and filter state. This extends the existing tools rather 
than adding a resolver round trip: their response models already carry 
dashboard metadata and state, so transparent resolution keeps the workflow 
discoverable without losing context.
   
   Invalid or expired permalinks return an actionable error asking for a fresh 
shared link. Numeric IDs, UUIDs, and slugs retain their existing lookup path; 
ambiguous bare strings are attempted as permalinks only after ordinary 
identifier lookup fails.
   
   > **This supersedes #42659**, which GitHub closed permanently when the 
source fork repository was deleted ("state cannot be changed. The repository 
that submitted this pull request has been deleted"). The fork has been 
recreated, but a recreated fork gets a new internal ID, so the original PR 
cannot be reopened. The code here is the same work, rebased onto current 
`master`. Review history from #42659 is summarized below so it is not lost.
   
   ### Carried-over review history from #42659
   
   #42659 was reviewed by @gabotorresruiz, who raised two issues and 
subsequently approved. Both fixes are included here:
   
   1. **UUID `dashboardId`** — `CreateDashboardPermalinkCommand` stores 
`str(dashboard.uuid)`, so the original `int(...)` comparison failed for 
virtually every real permalink, dropping shared state with a spurious "belongs 
to a different dashboard" warning. `get_matching_dashboard_permalink_state` now 
compares the reference against id, uuid **and** slug (slug covers pre-3.1 
permalinks), and `DashboardLookupResult.resolved_from_permalink` marks the 
permalink-only path so it skips re-verification entirely.
   2. **Swallowed not-found error** — a mistyped slug returned the permalink 
message ("ask for a fresh shared dashboard link") instead of naming the 
identifier. Both tools now keep the identifier's own error whenever `result is 
not None`, reserving the permalink wording for permalink-only requests.
   
   A bot review also flagged that `lookup_dashboard_reference` had no direct 
tests despite four branching paths; nine direct tests were added covering each 
resolution path.
   
   This branch was additionally rebased across #43202 ("preserve user-authored 
result values"), which removed `sanitize_for_llm_context` service-wide and 
rewrote `_apply_permalink_state` to use `model_copy`. Both were reconciled 
rather than resolved in this branch's favour: the removed sanitization call was 
dropped (the privacy redaction via `user_can_view_data_model_metadata` is 
retained, since that is access control rather than value rewriting) and 
master's `model_copy` form was kept.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable; this changes MCP tool behavior and schemas only.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest -q tests/unit_tests/mcp_service/dashboard/
   pre-commit run --files superset/mcp_service/app.py 
superset/mcp_service/dashboard/permalink.py 
superset/mcp_service/dashboard/schemas.py 
superset/mcp_service/dashboard/tool/get_dashboard_info.py 
superset/mcp_service/dashboard/tool/get_dashboard_layout.py 
tests/unit_tests/mcp_service/dashboard/test_dashboard_schemas.py 
tests/unit_tests/mcp_service/dashboard/test_permalink.py 
tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py 
tests/unit_tests/mcp_service/dashboard/tool/test_get_dashboard_layout.py
   ```
   
   The dashboard MCP unit suite passes (411 tests). Changed-file pre-commit 
passes, including mypy, ruff and pylint.
   
   Coverage worth noting:
   - UUID-string `dashboardId` asserting `filter_state` is present, for 
**both** tools (`test_dashboard_tools.py`, `test_get_dashboard_layout.py`), 
plus a slug case for pre-3.1 permalinks.
   - Typo/unknown-slug tests asserting the error message names the identifier, 
for both tools.
   - Nine direct `lookup_dashboard_reference` tests. These were 
mutation-checked: removing the identifier-precedence guard, forcing 
`resolved_from_permalink=False`, and disabling permalink-URL extraction each 
cause failures, so the tests pin behaviour rather than merely passing.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   #### Blast radius
   
   Apache Superset's optional MCP service only. No migrations, feature flags, 
authentication changes, workspace isolation changes, or database query behavior 
changes.
   
   #### Risk and rollback
   
   The main risk is interpreting an unknown slug-like identifier as a permalink 
after normal lookup fails. Existing identifiers are resolved first, and 
reverting this commit restores the previous behavior.
   
   #### Cost and latency delta
   
   No model, prompt-routing, or token changes. A bare permalink key can add one 
permalink lookup after an unsuccessful ordinary identifier lookup; explicit 
permalink inputs and shared URLs resolve directly.
   
   #### Prompt / non-determinism
   
   Tool descriptions were updated to identify `/dashboard/p/<key>/` links and 
direct agents to the lookup tools. The resolution behavior is deterministic; no 
model prompt or routing behavior changed.
   
   #### Review guidance
   
   Start with `dashboard/permalink.py` and the request/response schema changes, 
then review how each lookup tool reuses the resolved dashboard ID and safely 
exposes permalink state. The most important behavior is the 
ordinary-identifier-first fallback for bare strings.
   


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