gkneighb opened a new pull request, #40397:
URL: https://github.com/apache/superset/pull/40397
### SUMMARY
`list_charts` previously restricted filter columns to `slice_name`,
`viz_type`, `datasource_name`, `created_by_fk`, and `changed_by_fk`. The REST
API has supported filtering by the `dashboards` relationship since the chart
list endpoint shipped — it appears in `search_columns` in
`superset/charts/api.py` — but the MCP schema arbitrarily restricted it.
Without that filter, finding *"all charts attached to dashboard X"* via MCP
required calling `get_dashboard_info` and walking the nested `charts` array,
which is awkward to compose with other filters or pagination.
This PR adds `dashboards` as a permitted filter column and makes the
underlying DAO machinery understand it.
### BEFORE/AFTER
**Before:**
```
list_charts({filters:[{col:"dashboards", opr:"eq", value:42}]})
→ ValidationError: Input should be 'slice_name', 'viz_type',
'datasource_name', 'created_by_fk' or 'changed_by_fk'
```
**After:**
```
list_charts({filters:[{col:"dashboards", opr:"eq", value:42}]})
→ {charts: [...the 5 charts on dashboard 42...]}
```
### CHANGES
Two changes:
1. **`superset/mcp_service/chart/schemas.py`** — add `"dashboards"` to the
`ChartFilter.col` literal so the schema validator accepts it; update the field
description so an LLM consumer knows it's there.
2. **`superset/daos/base.py`** — generalize `apply_column_operators` so the
`eq` operator on a many-to-many relationship column dispatches to
`column.any(<related_pk> == value)` instead of trying to compare a collection
to a scalar. The fix is generic and applies to every DAO that inherits
`BaseDAO`, not just `Slice` — every m2m column on every DAO now supports `eq`
filtering by related id.
The DAO change is additive and backward-compatible: scalar columns continue
using the existing scalar comparison path.
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/daos/test_base_relationship_filters.py
pytest tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
```
New tests:
- `tests/unit_tests/daos/test_base_relationship_filters.py` — verifies the
dispatch path for relationship vs scalar columns, plus the existing
invalid-column behavior is preserved.
- Two added cases in
`tests/unit_tests/mcp_service/chart/tool/test_list_charts.py::TestListChartsRequestSchema`
— assert the schema accepts `dashboards` and rejects unknown columns.
Existing 21 `list_charts` tests still pass.
### ADDITIONAL INFORMATION
- [ ] Has associated issue: _(filing alongside, will link)_
- [ ] Required feature flags: _none_
- [x] Changes UI: _no_
- [x] Includes DB Migration: _no_
- [x] Includes packaged template files: _no_
- [x] Introduces new feature or API: _adds a previously-unavailable filter
column to the existing `list_charts` MCP tool_
- [x] Removes existing feature or API: _no_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]