[mcp] fix read_data_product under restrict_to_user_objects#36999
Open
mtabebe wants to merge 1 commit into
Open
[mcp] fix read_data_product under restrict_to_user_objects#36999mtabebe wants to merge 1 commit into
mtabebe wants to merge 1 commit into
Conversation
Problem: The lookup query in `read_data_product` called `has_cluster_privilege`, whose body references `mz_catalog.mz_roles`. Those resolved IDs propagate into the caller, so the user object restriction check fires on `mz_roles` and the tool fails. Solution: Rewrite the lookup to `LEFT JOIN mz_show_my_cluster_privileges` instead of calling the function. Two supporting changes for that - Swap `pg_has_role` for `mz_session_role_memberships()` in the `mz_show_my_*_privileges` views (same pattern already on `mz_show_my_object_privileges`), so their bodies don't pull `mz_roles` in either. - Allow-list `mz_show_my_cluster_privileges` the restriction check gates on item identity, not body, so the body fix alone isn't enough. Testing: SLT regression pin in `rbac_mcp_agent.slt` for the new lookup query, and a `test_mcp_agent_restricted` MCP integration test that runs the agent endpoint with `restrict_to_user_objects = true`.
jubrad
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
The lookup query in
read_data_productcalledhas_cluster_privilege, whose body referencesmz_catalog.mz_roles. Those resolved IDs propagate into the caller, so the user object restriction check fires onmz_rolesand the tool fails.Solution:
Rewrite the lookup to
LEFT JOIN mz_show_my_cluster_privilegesinstead of calling the function.Two supporting changes for that
pg_has_roleformz_session_role_memberships()in themz_show_my_*_privilegesviews (same pattern already onmz_show_my_object_privileges), so their bodies don't pullmz_rolesin either.mz_show_my_cluster_privilegesthe restriction check gates on item identity, not body, so the body fix alone isn't enough.Testing:
SLT regression pin in
rbac_mcp_agent.sltfor the new lookup query, and atest_mcp_agent_restrictedMCP integration test that runs the agent endpoint withrestrict_to_user_objects = true.