You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "guilleov (via GitHub)" <gi...@apache.org> on 2026/07/13 15:19:37 UTC
[PR] feat(mcp): support owners in update_dashboard tool [superset]
guilleov opened a new pull request, #42002:
URL: https://github.com/apache/superset/pull/42002
### SUMMARY
The MCP `update_dashboard` tool can edit a dashboard's title, description, slug, `published` flag, tags, CSS, layout and `json_metadata`, but it had **no way to set the dashboard's owners** (and no other MCP tool sets owners either).
Because of this, a dashboard created through the MCP (`generate_dashboard`) is owned only by the MCP agent's user. An unpublished dashboard is visible only to its owners, so the human driving the agent cannot see or manage their own new dashboard, and no MCP client can transfer ownership to them. The only workarounds today are the Superset UI or direct metadata-DB access.
This PR adds an optional `owners` field to `update_dashboard`: a full-replacement list of user IDs, mirroring the REST dashboard owners semantics.
- Unknown user IDs are rejected up front with an `OwnersNotFound` error.
- An empty list clears all owners.
- Omitting the field leaves owners unchanged.
Editorship is still enforced via `raise_for_editorship`, so only current owners or an Admin can change owners (same guarantee as the REST PUT).
Discussion: https://github.com/apache/superset/discussions/42001
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — MCP tool schema/behavior change, no UI.
### TESTING INSTRUCTIONS
Unit tests added in `tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py`:
- `test_update_owners_replaces_list` — owners fully replaced with the resolved users; `owners` appears in `changed_fields`.
- `test_update_owners_unknown_id_errors` — an unknown ID returns `OwnersNotFound` with no mutation and no commit.
Manual: call `update_dashboard` with `{"identifier": <id>, "owners": [<user_id>, ...]}` and verify owners change; a non-existent ID returns `OwnersNotFound`; an empty list clears owners; omitting the field leaves owners unchanged.
### ADDITIONAL INFORMATION
- [x] Has associated issue: linked GitHub Discussion apache/superset#42001 (this repo routes feature requests to Discussions)
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
> Note: unit tests were added and the changed files pass `py_compile`, but the full test suite / pre-commit were not run locally (no dev environment available in this setup). Relying on CI to validate formatting, typing and tests.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "guilleov (via GitHub)" <gi...@apache.org>.
guilleov commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3578246734
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -203,6 +227,15 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). IDs are
+ # validated up front in _validate_update_request, so resolving here
+ # only maps the already-verified IDs to user objects.
+ owner_users: list[Any]
+ owner_users, _missing = _resolve_owners(request.owners)
+ dashboard.owners = owner_users
+ changed.append("owners")
+
Review Comment:
Addressed in 677e531: owners are now resolved and validated exactly once in `_resolve_and_validate_owners`, and the resolved list is passed to `_apply_field_updates` for the write. There is no longer a second lookup at mutation time, so a user removed between validation and the write can no longer be silently dropped.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-4968674573
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-4959552057
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-4959848936
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42002?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `8.69565%` with `21 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 64.21%. Comparing base ([`8f75f1a`](https://app.codecov.io/gh/apache/superset/commit/8f75f1a353dbcb8eafff4e98fbfb19cf6b33ca44?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`438497f`](https://app.codecov.io/gh/apache/superset/commit/438497f97db5345b3bba648a519a778c444c1313?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/42002?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...set/mcp\_service/dashboard/tool/update\_dashboard.py](https://app.codecov.io/gh/apache/superset/pull/42002?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fdashboard%2Ftool%2Fupdate_dashboard.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvZGFzaGJvYXJkL3Rvb2wvdXBkYXRlX2Rhc2hib2FyZC5weQ==) | 4.54% | [21 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/42002?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #42002 +/- ##
==========================================
+ Coverage 56.13% 64.21% +8.07%
==========================================
Files 2744 2744
Lines 153571 153594 +23
Branches 35212 35218 +6
==========================================
+ Hits 86213 98623 +12410
+ Misses 66532 53074 -13458
- Partials 826 1897 +1071
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/42002/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/42002/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.05% <8.69%> (-0.01%)` | :arrow_down: |
| [presto](https://app.codecov.io/gh/apache/superset/pull/42002/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.04% <8.69%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/42002/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.72% <8.69%> (+16.61%)` | :arrow_up: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/42002/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.57% <8.69%> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42002?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-4966911990
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 6be4201c00a9c9164c98e0faf2934749e81a85f1 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a55f20700d04400089d8de9 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-42002--superset-docs-preview.netlify.app](https://deploy-preview-42002--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcoxDoAgDADAv3SW2BhR9Ac-o9gaB4EGMcYY_y7bDfeC5hS0wAzQgM8U1716EyptWNVcylTEMJ27T5TZpDtKPutl0SM9C9c9kLVbhyMiY98jopvYsUzw_Q) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-42002--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support editors in update_dashboard tool [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-5046704461
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3577258373
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -203,6 +227,15 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). IDs are
+ # validated up front in _validate_update_request, so resolving here
+ # only maps the already-verified IDs to user objects.
+ owner_users: list[Any]
+ owner_users, _missing = _resolve_owners(request.owners)
+ dashboard.owners = owner_users
+ changed.append("owners")
+
Review Comment:
**Suggestion:** The owner IDs are resolved a second time during mutation, but unresolved IDs are ignored in this phase. If a user is deleted between validation and apply, the update will still commit with a silently truncated owner list instead of returning `OwnersNotFound`, violating the full-replacement contract. Reuse the validated resolved users from the validation step (or re-check `_missing` and fail) so owner replacement is atomic and deterministic. [race condition]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
⚠️ MCP update_dashboard owner replacement can be nondeterministic.
⚠️ Concurrent user deletion silently truncates requested owner list.
⚠️ Full-replacement owners semantics violated under concurrent changes.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Start Superset with the MCP service and ensure the `update_dashboard` tool is
available; the tool entrypoint is defined in
`superset/mcp_service/dashboard/tool/update_dashboard.py:333-418` in the
`update_dashboard(request: UpdateDashboardRequest, ctx: Context)` function.
2. Trigger an update via MCP as in
`tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py:144-162`, calling
the tool with a non-empty owners list, for example `{"identifier": 42, "owners": [5, 9]}`
so that both user IDs initially exist and resolve in `security_manager.get_user_by_id`.
3. During the same tool call, the handler in `update_dashboard` first runs
`_validate_update_request(dashboard, request)` at
`superset/mcp_service/dashboard/tool/update_dashboard.py:123-201`, which calls
`_resolve_owners(request.owners)` at lines 177-185; both IDs (5 and 9) resolve,
`missing_owner_ids` is empty, and validation succeeds, allowing the request to proceed.
4. Before `_apply_field_updates(dashboard, request)` is executed (invoked in the
`update_dashboard` body at
`superset/mcp_service/dashboard/tool/update_dashboard.py:382-387`), another process
deletes user ID 9 so that `security_manager.get_user_by_id(9)` now returns `None`; when
`_apply_field_updates` reaches the owners branch at lines 230-238, it calls
`_resolve_owners(request.owners)` a second time, receives `users=[user5]` and
`missing=[9]`, but ignores `_missing` and sets `dashboard.owners = owner_users` followed
by `db.session.commit()` at lines 58-58, silently dropping the requested owner 9 without
returning an `OwnersNotFound` error despite the full-replacement contract.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a18c91fd5d1740739edee98db35b6bd6&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=a18c91fd5d1740739edee98db35b6bd6&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/update_dashboard.py
**Line:** 235:238
**Comment:**
*Race Condition: The owner IDs are resolved a second time during mutation, but unresolved IDs are ignored in this phase. If a user is deleted between validation and apply, the update will still commit with a silently truncated owner list instead of returning `OwnersNotFound`, violating the full-replacement contract. Reuse the validated resolved users from the validation step (or re-check `_missing` and fail) so owner replacement is atomic and deterministic.
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%2F42002&comment_hash=11e2b7ebaedd411a7a168aaec8e8d0b57e469a27688a697d0a67456ebb3ff578&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42002&comment_hash=11e2b7ebaedd411a7a168aaec8e8d0b57e469a27688a697d0a67456ebb3ff578&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "guilleov (via GitHub)" <gi...@apache.org>.
guilleov commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3578221936
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -203,6 +227,14 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). IDs are
+ # validated up front in _validate_update_request, so resolving here
+ # only maps the already-verified IDs to user objects.
+ users, _missing = _resolve_owners(request.owners)
Review Comment:
Addressed in 6be4201: annotated the unpacking as `owner_users: list[Any]`.
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -260,6 +292,20 @@ def _validate_update_request(
error_type="DatabaseError",
)
+ # A non-empty owners list must reference existing users. An empty list is
+ # a valid "clear all owners" request and needs no lookup.
+ if request.owners:
+ _users, missing = _resolve_owners(request.owners)
Review Comment:
Addressed in 6be4201: annotated `missing_owner_ids: list[int]` on the validation unpacking.
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -260,6 +292,20 @@ def _validate_update_request(
error_type="DatabaseError",
)
+ # A non-empty owners list must reference existing users. An empty list is
+ # a valid "clear all owners" request and needs no lookup.
+ if request.owners:
+ _users, missing = _resolve_owners(request.owners)
+ if missing:
+ return DashboardError(
+ error=(
+ "Unknown owner user IDs: "
+ + ", ".join(str(m) for m in missing)
+ + ". Find valid IDs with list_users."
+ ),
+ error_type="OwnersNotFound",
+ )
Review Comment:
Addressed in 6be4201: owner resolution in validation is now wrapped in `except SQLAlchemyError`, returning a structured `DatabaseError` like the tag validation path.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3594814995
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -164,14 +164,81 @@ def _collect_metadata_overrides(request: UpdateDashboardRequest) -> dict[str, An
return overrides
-def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> list[str]:
+def _resolve_owners(owner_ids: list[int]) -> tuple[list[Any], list[int]]:
+ """Resolve owner user IDs to user objects.
+
+ Returns ``(users, missing_ids)``, deduplicating IDs while preserving the
+ caller's order. ``security_manager`` is imported lazily for the same
+ app-context reason as ``_find_and_authorize_dashboard``.
+ """
+ from superset import security_manager
+
+ users: list[Any] = []
+ missing: list[int] = []
+ seen: set[int] = set()
+ for uid in owner_ids:
+ if uid in seen:
+ continue
+ seen.add(uid)
+ user = security_manager.get_user_by_id(uid)
Review Comment:
These are FAB `User` rows, but the editors relationship takes `Subject` rows — different objects and a different ID space than `list_users` returns; resolution should go through `populate_subject_list` / `get_or_create_user_subject`.
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -328,12 +408,18 @@ def update_dashboard(
if validation_error is not None:
return validation_error
+ # Resolve owners once up front so the same list is used for validation and
+ # the write (no second lookup that could drop a concurrently-removed user).
+ resolved_owners, owners_error = _resolve_and_validate_owners(request)
Review Comment:
REST goes through `compute_subjects` → `compute_subject_list(..., ensure_no_lockout=True)` so a non-admin can't remove themselves — should this path do the same, or is self-lockout intended?
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -214,6 +281,14 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). The owners were
+ # resolved and validated exactly once by _resolve_and_validate_owners,
+ # so there is no second lookup here that could silently drop a user
+ # removed between validation and this write.
+ dashboard.owners = resolved_owners or []
Review Comment:
`Dashboard` has no `owners` relationship (only `editors`/`viewers` → `Subject`), so this sets a stray instance attribute and persists nothing while `changed_fields` still reports `"owners"` — the tests pass only because `dash` is a `Mock`.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3571864620
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -260,6 +292,20 @@ def _validate_update_request(
error_type="DatabaseError",
)
+ # A non-empty owners list must reference existing users. An empty list is
+ # a valid "clear all owners" request and needs no lookup.
+ if request.owners:
+ _users, missing = _resolve_owners(request.owners)
Review Comment:
**Suggestion:** Annotate the variable holding missing owner IDs in this new unpacking statement so the added validation path remains type-explicit. [custom_rule]
**Severity Level:** Minor 🧹
<details>
<summary><b>Why it matters? ⭐ </b></summary>
This is another new unpacking assignment that omits an explicit type annotation for the local variable `missing`, which can be annotated. That is a real violation of the type-hint rule.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7030d6de09154639b88e42f5f9c1713d&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=7030d6de09154639b88e42f5f9c1713d&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/update_dashboard.py
**Line:** 298:298
**Comment:**
*Custom Rule: Annotate the variable holding missing owner IDs in this new unpacking statement so the added validation path remains type-explicit.
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%2F42002&comment_hash=a429fe79230adff027ffe98c242c134de1ac2a59b48c047fb44fff263e28e102&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42002&comment_hash=a429fe79230adff027ffe98c242c134de1ac2a59b48c047fb44fff263e28e102&reaction=dislike'>👎</a>
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -203,6 +227,14 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). IDs are
+ # validated up front in _validate_update_request, so resolving here
+ # only maps the already-verified IDs to user objects.
+ users, _missing = _resolve_owners(request.owners)
Review Comment:
**Suggestion:** Add an explicit type annotation for the resolved owners variables (or annotate the retained variable after unpacking) so this new assignment is fully typed. [custom_rule]
**Severity Level:** Minor 🧹
<details>
<summary><b>Why it matters? ⭐ </b></summary>
The new unpacking assignment introduces local variables without an explicit type annotation even though the variable shapes are known from the helper return type. This matches the rule requiring type hints for new or modified Python variables that can be annotated.
</details>
<details>
<summary><b>Rule source 📖 </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=41ed2536facd4bcb8e49bc6e2f1baf86&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=41ed2536facd4bcb8e49bc6e2f1baf86&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/update_dashboard.py
**Line:** 234:234
**Comment:**
*Custom Rule: Add an explicit type annotation for the resolved owners variables (or annotate the retained variable after unpacking) so this new assignment is fully typed.
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%2F42002&comment_hash=aa66ae2fea5d60ff1ba05bb212c0816340b75c15ec641e28099d3ca278aa9a6b&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42002&comment_hash=aa66ae2fea5d60ff1ba05bb212c0816340b75c15ec641e28099d3ca278aa9a6b&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support editors in update_dashboard tool [superset]
Posted by "guilleov (via GitHub)" <gi...@apache.org>.
guilleov closed pull request #42002: feat(mcp): support editors in update_dashboard tool
URL: https://github.com/apache/superset/pull/42002
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3598046329
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -164,14 +164,81 @@ def _collect_metadata_overrides(request: UpdateDashboardRequest) -> dict[str, An
return overrides
-def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> list[str]:
+def _resolve_owners(owner_ids: list[int]) -> tuple[list[Any], list[int]]:
+ """Resolve owner user IDs to user objects.
+
+ Returns ``(users, missing_ids)``, deduplicating IDs while preserving the
+ caller's order. ``security_manager`` is imported lazily for the same
+ app-context reason as ``_find_and_authorize_dashboard``.
+ """
+ from superset import security_manager
+
+ users: list[Any] = []
+ missing: list[int] = []
+ seen: set[int] = set()
+ for uid in owner_ids:
+ if uid in seen:
+ continue
+ seen.add(uid)
+ user = security_manager.get_user_by_id(uid)
Review Comment:
Related to the line-289 issue: even once this targets `editors` instead of `owners`, `get_user_by_id` returns FAB `User` rows, but `editors` expects `Subject` rows — a different ID space. `generate_dashboard.py` in this same directory already has the right pattern (`get_user_subject(user.id)` before assigning to `dashboard.editors`), and REST's `UpdateDashboardCommand` goes through `compute_subjects` → `compute_subject_list` → `populate_subject_list`/`get_or_create_user_subject` in `commands/utils.py`. Reusing that helper here would fix this and the line-289 issue together and keep owner-resolution semantics in sync with REST.
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -328,12 +408,18 @@ def update_dashboard(
if validation_error is not None:
return validation_error
+ # Resolve owners once up front so the same list is used for validation and
+ # the write (no second lookup that could drop a concurrently-removed user).
+ resolved_owners, owners_error = _resolve_and_validate_owners(request)
Review Comment:
Building on msyavuz's question above: once this is wired to `editors` correctly, worth deciding explicitly whether to add the same `ensure_no_lockout=True` guard REST uses in `compute_subjects`, so a non-admin can't remove themselves from the editor list via this tool. If the omission is intentional it'd be good to say so, otherwise it's an easy way to get locked out of a dashboard you still need to edit.
##########
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py:
##########
@@ -137,6 +137,119 @@ async def test_update_layout_theme_and_css(
changed = set(payload.get("changed_fields") or [])
assert {"position_json", "json_metadata", "css"} <= changed
+ @patch("superset.security_manager.get_user_by_id")
+ @patch("superset.daos.dashboard.DashboardDAO.get_by_id_or_slug")
+ @patch("superset.extensions.db.session")
+ @pytest.mark.asyncio
+ async def test_update_owners_replaces_list(
Review Comment:
Good coverage overall on the input-handling side. One gap: `test_non_editor_gets_permission_denied` (further down in this file) only exercises `dashboard_title`, not `owners`. The editorship gate runs before any field-specific logic so it should cover `owners` too, but a direct test for that — ideally against something more realistic than `Mock()` for the dashboard — would likely have caught the persistence issue flagged above before this merged.
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -214,6 +281,14 @@ def _apply_field_updates(dashboard: Any, request: UpdateDashboardRequest) -> lis
update_tags(ObjectType.dashboard, dashboard.id, dashboard.tags, request.tags)
changed.append("tags")
+ if request.owners is not None:
+ # Full replacement of owners (empty list clears them). The owners were
+ # resolved and validated exactly once by _resolve_and_validate_owners,
+ # so there is no second lookup here that could silently drop a user
+ # removed between validation and this write.
+ dashboard.owners = resolved_owners or []
Review Comment:
Confirming and expanding on msyavuz's comment above: `Dashboard` doesn't actually have an `owners` relationship — only `editors`/`viewers` (Subject-based, see `superset/models/dashboard.py`). This line sets a plain, unmapped instance attribute, so `db.session.commit()` won't persist anything here against a real database. The unit tests pass only because `dash` is a `Mock()` that happily accepts any attribute assignment. `changed_fields` will still report `"owners"` and the tool will return success, so a caller has no way to tell the write silently no-op'd. This needs to route through `editors` the way the sibling `generate_dashboard.py` tool and the REST `UpdateDashboardCommand` do — see the note on line 183 below.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "guilleov (via GitHub)" <gi...@apache.org>.
guilleov commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-4990970059
hi @aminghadersohi @msyavuz, don't know if you guys are the correct to review this pr but i hope you can take a look, thankssss
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support editors in update_dashboard tool [superset]
Posted by "guilleov (via GitHub)" <gi...@apache.org>.
guilleov commented on PR #42002:
URL: https://github.com/apache/superset/pull/42002#issuecomment-5056135247
Ok, thanks for your review on it! @aminghadersohi
I'll close the PR 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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(mcp): support owners in update_dashboard tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #42002:
URL: https://github.com/apache/superset/pull/42002#discussion_r3571901246
##########
superset/mcp_service/dashboard/tool/update_dashboard.py:
##########
@@ -260,6 +292,20 @@ def _validate_update_request(
error_type="DatabaseError",
)
+ # A non-empty owners list must reference existing users. An empty list is
+ # a valid "clear all owners" request and needs no lookup.
+ if request.owners:
+ _users, missing = _resolve_owners(request.owners)
+ if missing:
+ return DashboardError(
+ error=(
+ "Unknown owner user IDs: "
+ + ", ".join(str(m) for m in missing)
+ + ". Find valid IDs with list_users."
+ ),
+ error_type="OwnersNotFound",
+ )
Review Comment:
**Suggestion:** Owner validation does database lookups without handling database exceptions, and this block runs before the tool’s SQLAlchemy error wrapper. If the user lookup query fails (for example during transient DB issues), the exception escapes as an unhandled tool failure instead of returning the structured `DatabaseError` response used elsewhere in this function. Wrap owner resolution in `except SQLAlchemyError` and return a consistent `DashboardError`. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Owner validation can crash update_dashboard on database errors.
- ⚠️ MCP clients receive unstructured internal errors for owner lookups.
- ⚠️ Owner changes unavailable during transient database connectivity issues.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Invoke the MCP `update_dashboard` tool defined at
`superset/mcp_service/dashboard/tool/update_dashboard.py:63` with a request containing a
non-empty `owners` list (e.g. via FastMCP client invoking the `update_dashboard` tool).
2. The tool resolves the target dashboard via `_find_and_authorize_dashboard` at
`update_dashboard.py:53-99`, then calls `_validate_update_request(dashboard, request)` at
`update_dashboard.py:362-364` **outside** the surrounding `try/except SQLAlchemyError`
block that begins at `update_dashboard.py:112`.
3. Inside `_validate_update_request` at `update_dashboard.py:241-250`, when it reaches the
owners validation block at `update_dashboard.py:295-308`, it calls
`_resolve_owners(request.owners)` (definition at `update_dashboard.py:156-177`), which in
turn performs `security_manager.get_user_by_id(uid)` using SQLAlchemy-backed models.
4. During this lookup, simulate a transient database failure (e.g. disconnect or statement
error) so that `security_manager.get_user_by_id` raises `SQLAlchemyError`; because this
occurs in `_validate_update_request` before any local `try/except SQLAlchemyError` and
before the main `update_dashboard` `try/except SQLAlchemyError` (which only wraps
`_apply_field_updates` and `db.session.commit` at `update_dashboard.py:112-153`), the
exception bubbles up unhandled, causing the MCP tool call to fail with an internal error
instead of returning a structured `DashboardError(error_type="DatabaseError")` like the
tag-validation block at `update_dashboard.py:22-34`.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=df7c301fc1864762be532188239574d4&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=df7c301fc1864762be532188239574d4&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/update_dashboard.py
**Line:** 297:307
**Comment:**
*Logic Error: Owner validation does database lookups without handling database exceptions, and this block runs before the tool’s SQLAlchemy error wrapper. If the user lookup query fails (for example during transient DB issues), the exception escapes as an unhandled tool failure instead of returning the structured `DatabaseError` response used elsewhere in this function. Wrap owner resolution in `except SQLAlchemyError` and return a consistent `DashboardError`.
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%2F42002&comment_hash=23e87834919d5f6a1f7ed03ed754bd5710b57387117b0b0eedbc2c7911064878&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42002&comment_hash=23e87834919d5f6a1f7ed03ed754bd5710b57387117b0b0eedbc2c7911064878&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org