aminghadersohi opened a new pull request, #37185:
URL: https://github.com/apache/superset/pull/37185
### SUMMARY
Add shared validation utility to detect missing/deleted datasets in MCP
chart tools. This prevents confusing errors when users try to preview or get
data from charts whose datasets have been deleted.
**Problem**: When a chart's dataset is deleted, the MCP tools would return
confusing errors or fail silently. Users would see "Missing dataset" errors in
the UI without clear indication of what went wrong.
**Solution**: Added a shared `validate_chart_dataset()` utility that:
- Checks if a chart's dataset exists and is accessible
- Returns clear error messages when datasets are missing/deleted
- Warns about virtual (SQL Lab) datasets that could be deleted
**Changes**:
- Added `validate_chart_dataset()` utility in `chart_utils.py`
- Updated `generate_chart` to validate dataset after chart creation (adds
warnings to response)
- Updated `get_chart_info` to return `ChartError` with type
`DatasetNotAccessible` if dataset is missing
- Updated `get_chart_preview` to validate before generating preview
- Updated `get_chart_data` to validate before fetching data
- Added documentation in MCP `CLAUDE.md`
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend changes only
### TESTING INSTRUCTIONS
1. Create a chart using the MCP `generate_chart` tool
2. Delete the dataset the chart uses (via UI or API)
3. Try to get chart info, preview, or data using the MCP tools:
- `get_chart_info` - Should return `ChartError` with `error_type:
"DatasetNotAccessible"`
- `get_chart_preview` - Should return `ChartError` with clear message
about missing dataset
- `get_chart_data` - Should return `ChartError` with clear message about
missing dataset
### 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
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]