fix(mcp): exclude self-referencing filter columns from get_schema output#39826
fix(mcp): exclude self-referencing filter columns from get_schema output#39826
Conversation
After #39638, chart/dataset/dashboard ModelGetSchemaCore instances had no exclude_filter_columns set, so get_schema(model_type='chart|dataset|dashboard') still advertised created_by_fk and owner in filter_columns. LLMs would call get_schema to discover available filters, see those columns, and pass real user IDs directly — bypassing the created_by_me/owned_by_me server-side injection added in #39638. Pass SELF_REFERENCING_FILTER_COLUMNS as exclude_filter_columns for chart, dataset, and dashboard schema cores (the database core already excluded its user-directory columns via DATABASE_EXCLUDE_COLUMNS). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #d63c60Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #39826 +/- ##
==========================================
- Coverage 64.37% 63.89% -0.48%
==========================================
Files 2569 2583 +14
Lines 134682 136611 +1929
Branches 31253 31490 +237
==========================================
+ Hits 86698 87285 +587
- Misses 46485 47810 +1325
- Partials 1499 1516 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…d dataset The existing test only covered dashboard. Add parallel tests for chart and dataset to verify that created_by_fk, owner, and created_by_fk_or_owner are excluded from filter_columns even when the DAO returns them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Agent Run #c5edd6Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
aminghadersohi
left a comment
There was a problem hiding this comment.
The production change looks correct as defense-in-depth. Two concerns about the tests:
-
The mocks in
test_get_schema_chart_omits_self_referencing_filter_columnsand the dataset equivalent only returncreated_by_fkandowner, which are already excluded byUSER_DIRECTORY_FIELDSinModelGetSchemaCore.__init__(unconditionally, viaself.exclude_filter_columns.update(USER_DIRECTORY_FIELDS)) — these assertions pass even without this PR's fix. To actually exercise the newexclude_filter_columnsbehavior, include"created_by_fk_or_owner": ["eq"]in the mock return value and assert it's absent from the output. As written, reverting the production change would not cause any of the new tests to fail. -
_get_dashboard_schema_core()receives the sameexclude_filter_columns=set(SELF_REFERENCING_FILTER_COLUMNS)fix but has no corresponding test for self-referencing column exclusion.
Add `created_by_fk_or_owner` to the mock return values in the chart and dataset self-referencing filter tests so the exclusion is actually exercised (previously the assertion was vacuously true since the key was never in the mock). Also add a matching test for the dashboard schema core, which received the same exclude_filter_columns fix but had no corresponding coverage.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #c78dd6Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Regression from #39638:
get_schema(model_type='chart|dataset|dashboard')still advertisedcreated_by_fkandownerinfilter_columnsbecause the chart, dataset, and dashboardModelGetSchemaCoreinstances had noexclude_filter_columnsset.The LLM workflow that triggered the bug:
get_schema(model_type='chart')to discover available filter columnscreated_by_fkinfilter_columnsget_instance_infoto getcurrent_user.idlist_charts(request={"filters": [{"col": "created_by_fk", "opr": "eq", "value": 13}]})This bypasses the
created_by_me/owned_by_meserver-side injection added in #39638, re-exposing user IDs in tool calls.Fix: pass
SELF_REFERENCING_FILTER_COLUMNSasexclude_filter_columnsto the chart, dataset, and dashboardModelGetSchemaCoreinstances. The database schema core already had its user-directory columns excluded viaDATABASE_EXCLUDE_COLUMNS.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Manually verify
get_schemano longer advertisescreated_by_fkorowner:ADDITIONAL INFORMATION
Fixes regression introduced by #39638.