You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2026/10/03 14:40:48 UTC
[PR] fix(mcp): allow chart filtering by dataset ID [superset]
aminghadersohi opened a new pull request, #44950:
URL: https://github.com/apache/superset/pull/44950
## TL;DR
- Find charts by dataset ID instead of relying on non-unique dataset names.
- Support equality and membership filters, with matching schema discovery and unchanged access filtering.
### SUMMARY
Dataset IDs are already present on charts, but the MCP chart filter schema rejects `datasource_id`. This adds the column to `list_charts`, limits it to `eq`, `ne`, `in`, and `nin`, and advertises those operators through `get_schema`.
Equality operators require one integer; membership operators require a list of integers. Documentation and filter descriptions explain how to find charts on a dataset. Queries continue through the existing chart DAO and metadata-permission gate; no authorization or pagination behavior is changed.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable: no UI changes. Before, dataset ID filters were rejected; after, `{"col": "datasource_id", "opr": "eq", "value": 42}` selects charts querying dataset 42.
### TESTING INSTRUCTIONS
1. Call `get_schema` with `{"request": {"model_type": "chart"}}` and confirm `datasource_id` advertises `eq`, `ne`, `in`, and `nin`.
2. Call `list_charts` with `{"request": {"filters": [{"col": "datasource_id", "opr": "eq", "value": 42}], "select_columns": ["id", "datasource_id"]}}`, substituting an accessible dataset ID.
3. Check `ne` with an integer and `in`/`nin` with integer lists. Text and range operators should fail validation.
4. Run `pytest tests/unit_tests/mcp_service/chart/tool/test_list_charts.py tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py tests/unit_tests/mcp_service/system/tool/test_get_schema.py tests/unit_tests/mcp_service/chart/test_chart_schemas.py`.
Local results: 196 tests passed; staged-file pre-commit and explicit mypy checks passed.
## Eval evidence
All 26 added regression cases failed before the fix. After the fix, the 196-test targeted suite passes, covering actual SQL predicates for all four operators, value/operator rejection, discovery, and the existing metadata privacy gate. End-to-end conversational evaluations have not been run.
## Cost & latency delta
Not measured. No external calls or new datasource lookups are added; the filter uses the existing chart-list SQL query.
## Risk & rollback
Additive filter support; existing filter columns are unchanged. No database migration. Reverting this change removes the new filter option.
### 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
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44950:
URL: https://github.com/apache/superset/pull/44950#discussion_r4180318479
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Test placed outside class convention</b></div>
<div id="fix">
Every other test in this file lives in a class (`TestGetSchemaToolViaClient`, `TestGetSchemaEdgeCases`, `TestSchemaDiscoveryConstants`, ...); this chart-discovery test sits alone at module level below `TestGetSchemaPermissionMap`. Moving it into `TestGetSchemaToolViaClient` keeps all client-path `get_schema` tests discoverable in one place.
</div>
</div>
<small><i>Code Review Run #c425f9</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
+ """Chart discovery advertises the supported dataset ID operators."""
+ with patch.object(
+ get_schema_module, "user_can_view_data_model_metadata", return_value=True
+ ):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Redundant duplicate permission patch</b></div>
<div id="fix">
The autouse fixture `allow_data_model_metadata` (lines 69-77) already patches `get_schema_module.user_can_view_data_model_metadata` to True for every test in this module, so this identical `patch.object` wrapper is redundant. Dropping it keeps the test focused on the `datasource_id` contract and avoids a second patch site to maintain.
</div>
</div>
<small><i>Code Review Run #c425f9</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-6127686490
## CodeAnt PR Risk: Low Risk
- The PR appears safe to merge; dataset ID filters are limited to table-backed charts and enforce integer and operator validation.
- Regression tests cover same-ID semantic-view collisions across all four operators and preserve the metadata-permission gate.
**Assessed commit:** `675092871d91`
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #44950:
URL: https://github.com/apache/superset/pull/44950
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-6127674300
Thanks @geido — addressed all three non-blocking points:
1. Added “SQL datasets only” to the `datasource_id` filter column description, with a schema regression assertion: https://github.com/apache/superset/commit/675092871d9126538bffc855a64b0e936bd2d2b2
2. Used the sanitizer’s existing allowlisted `int_type` and `list_type` reasons so invalid values produce actionable type guidance. Added 36 wire-contract cases covering integer/list requirements, both response modes, middleware handling, and input redaction: https://github.com/apache/superset/commit/675092871d9126538bffc855a64b0e936bd2d2b2
3. Moved “Finding charts by dataset” out of the overview into its own `##` section and clarified that it applies to SQL datasets: https://github.com/apache/superset/commit/675092871d9126538bffc855a64b0e936bd2d2b2
Validation: `pytest tests/unit_tests/mcp_service -q` — 6,923 passed, 4 skipped, using the required FastMCP 3.4.7 and Trino 0.339.0 dependencies. Changed-file `pre-commit run` passed, including mypy, ruff, and pylint.
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44950:
URL: https://github.com/apache/superset/pull/44950#discussion_r4180462817
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
Review Comment:
Fixed in 107a98a69d131d8c0211aa1a3b479c23cc4d06e9. Moved the datasource_id discovery test into TestGetSchemaToolViaClient, matching the file's existing class grouping. No production behavior changed. Validation: system unit suite 161 passed; pre-commit passed on the touched file.
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
+ """Chart discovery advertises the supported dataset ID operators."""
+ with patch.object(
+ get_schema_module, "user_can_view_data_model_metadata", return_value=True
+ ):
Review Comment:
Fixed in 107a98a69d131d8c0211aa1a3b479c23cc4d06e9. Removed the duplicate permission patch; the module's autouse allow_data_model_metadata fixture already supplies the identical True return value. Validation: system unit suite 161 passed; pre-commit passed on the touched file.
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5986834464
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 an incremental AI Review.
- `/review full` - 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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5989088986
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 an incremental AI Review.
- `/review full` - 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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5970194686
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5970381096
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44950?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 `16.66667%` with `10 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.07%. Comparing base ([`549508b`](https://app.codecov.io/gh/apache/superset/commit/549508b340b2e411f8b8ba4c6172406f39706d7c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`15c0368`](https://app.codecov.io/gh/apache/superset/commit/15c036811a15a9edf86ee86ccda3063f29b4dcf8?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/44950?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/mcp\_service/chart/schemas.py](https://app.codecov.io/gh/apache/superset/pull/44950?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fschemas.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvc2NoZW1hcy5weQ==) | 16.66% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (549508b) and HEAD (15c0368). Click for more details.
>
> <details><summary>HEAD has 4 uploads less than BASE</summary>
>
>| Flag | BASE (549508b) | HEAD (15c0368) |
>|------|------|------|
>|python|7|3|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44950 +/- ##
===========================================
- Coverage 82.28% 66.07% -16.21%
===========================================
Files 2996 2996
Lines 185109 185121 +12
Branches 42834 42839 +5
===========================================
- Hits 152316 122324 -29992
- Misses 30031 60114 +30083
+ Partials 2762 2683 -79
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44950/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/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.30% <16.66%> (-0.01%)` | :arrow_down: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.17% <16.66%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.18% <16.66%> (-31.06%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.05% <16.66%> (-0.01%)` | :arrow_down: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/44950/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
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/44950?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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44950:
URL: https://github.com/apache/superset/pull/44950#discussion_r4179915296
##########
superset/daos/chart.py:
##########
@@ -36,6 +36,7 @@
# Custom filterable fields for charts
CHART_CUSTOM_FIELDS = {
+ "datasource_id": ["eq", "ne", "in", "nin"],
Review Comment:
Fixed in bc1b8f6f8af39e0ee698c5a6a4b146760f2c4ddd. Dataset ID filters require datasource_type = table in ChartDAO, the shared filter path used by list_charts. DAO and MCP regression tests cover same-ID semantic-view charts for eq, ne, in, and nin, verifying they are excluded. Validation: MCP suite plus chart DAO regressions: 6888 passed, 3 skipped; chart DAO/relationship tests: 27 passed; pre-commit passed on all branch-touched files.
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44950:
URL: https://github.com/apache/superset/pull/44950#discussion_r4180463415
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
Review Comment:
<!-- Bito Reply -->
The suggestion provided by the reviewer is appropriate. Moving the test into the existing class structure improves code organization and maintainability by keeping related tests grouped together, which is consistent with the file's established conventions.
##########
tests/unit_tests/mcp_service/system/tool/test_get_schema.py:
##########
@@ -643,3 +644,17 @@ async def test_resource_scope_is_enforced_when_rbac_disabled(self, app, mcp_serv
can_access.assert_not_called()
scope_allows.assert_called_once_with("read", "Chart")
+
+
+@pytest.mark.asyncio
+async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
+ """Chart discovery advertises the supported dataset ID operators."""
+ with patch.object(
+ get_schema_module, "user_can_view_data_model_metadata", return_value=True
+ ):
Review Comment:
<!-- Bito Reply -->
The suggestion to remove the redundant `patch.object` is appropriate. Since the autouse fixture `allow_data_model_metadata` already patches `get_schema_module.user_can_view_data_model_metadata` to `True` for all tests in the module, the additional patch is unnecessary and keeping it would introduce redundant maintenance overhead.
**tests/unit_tests/mcp_service/system/tool/test_get_schema.py**
```
@pytest.mark.asyncio
async def test_get_schema_chart_datasource_id(mcp_server: Any) -> None:
"""Chart discovery advertises the supported dataset ID operators."""
# The redundant patch.object has been removed.
```
--
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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5970211516
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 15c036811a15a9edf86ee86ccda3063f29b4dcf8 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6ac113f1a80455000893b26f |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44950--superset-docs-preview.netlify.app](https://deploy-preview-44950--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#DcrLDYAgDADQXXqWBPwQdQPHqAWCCQop9WCMu8vtHd4LhfNZBFaADnbGi2LzSUWlo4qiiCxVORSs-WbyKhxJPLfsfEn52VzrFsmYIRic9ThNWut5GfbeBvh-) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-44950--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] fix(mcp): allow chart filtering by dataset ID [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 #44950:
URL: https://github.com/apache/superset/pull/44950#discussion_r4179704124
##########
superset/daos/chart.py:
##########
@@ -36,6 +36,7 @@
# Custom filterable fields for charts
CHART_CUSTOM_FIELDS = {
+ "datasource_id": ["eq", "ne", "in", "nin"],
Review Comment:
**Suggestion:** A dataset ID is compared to `Slice.datasource_id` without checking `datasource_type`; if a semantic-view ID collides, charts on that view are incorrectly included as dataset matches.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes` · 🏷️ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=56d848dc63574bfca02e31fe4422fb75&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=56d848dc63574bfca02e31fe4422fb75&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/daos/chart.py
**Line:** 39:39
**Comment:**
*Logic Error: A dataset ID is compared to `Slice.datasource_id` without checking `datasource_type`; if a semantic-view ID collides, charts on that view are incorrectly included as dataset matches.
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%2F44950&comment_hash=52f983f97cfbf8677387e7dc3a91c90436f51ec2d3eed926d353b39e368930aa&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44950&comment_hash=52f983f97cfbf8677387e7dc3a91c90436f51ec2d3eed926d353b39e368930aa&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] fix(mcp): allow chart filtering by dataset ID [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44950:
URL: https://github.com/apache/superset/pull/44950#issuecomment-5985403253
<!-- Bito Reply -->
The flagged issue is valid. The current implementation of `datasource_id` filtering in `superset/daos/chart.py` and `superset/mcp_service/chart/schemas.py` relies solely on the `datasource_id` column, which can lead to collisions if different datasource types (e.g., datasets vs. semantic views) share the same ID.
To resolve this, you should update the filter logic to include `datasource_type` as a required companion field when filtering by `datasource_id`. This ensures that the query correctly distinguishes between different types of datasources.
Would you like me to fetch all comments and implement a fix for this and the rest of the PR comments?
**superset/mcp_service/chart/schemas.py**
```
@model_validator(mode="after")
def validate_datasource_id_filter(self) -> Self:
"""Restrict dataset ID filters to integer equality and membership."""
if self.col != "datasource_id":
return self
# ... existing validation ...
# ADDITION: Ensure datasource_type is also provided or handled
return self
```
--
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