justinpark opened a new pull request, #42877:
URL: https://github.com/apache/superset/pull/42877
### SUMMARY
`get_chart_data`, `get_chart_preview`,
`preview_utils.generate_preview_from_form_data`, and `generate_chart` all had
exception handlers that caught `SupersetSecurityException` (and other
`SupersetErrorException` subclasses) but discarded the real `error_type` (e.g.
`TABLE_SECURITY_ACCESS_ERROR`) and any `extra` payload the exception carried,
always reporting a generic tool-specific type (`DataError`, `ASCIIError`,
`chart_generation_error`, etc.) instead.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
```
{
"error_type": "DataError",
"error": "<UNTRUSTED-CONTENT>\nError retrieving chart data: You do not
have access to the following tables: db.tbl\n</UNTRUSTED-CONTENT>"
}
```
After:
```
{
"error_type": "TABLE_SECURITY_ACCESS_ERROR",
"error": "<UNTRUSTED-CONTENT>\nError retrieving chart data: You do not
have access to the following tables: db.tbl extra: {'entities': {'db.tbl':
{'requests': []}}, 'type': 'HIVE'}\n</UNTRUSTED-CONTENT>"
}
```
### TESTING INSTRUCTIONS
- [x] `security_error_utils.py` unit tests covering plain exceptions (no
`.error`/`.extra`), a security exception with `extra`, one without,
and the exact text format produced when `extra` is embedded in a
message
- [x] `get_chart_data.py`: end-to-end `Client(mcp_server).call_tool(...)`
tests for both the saved-chart and `form_data_key` paths
- [x] `get_chart_preview.py`: per-strategy tests (ASCII/Table/VegaLite) plus
a plain-error control case
- [x] `preview_utils.py`: security-error and plain-error cases
- [x] `generate_chart.py`: confirms `SupersetException` is now caught, the
real `error_type` surfaces, and `extra` is deliberately **not**
appended to the message
- [x] Full `tests/unit_tests/mcp_service/` suite passes (pre-existing
unrelated failures in `test_jwt_verifier`/`test_mcp_e2e_smoke`/
`test_tool_search_transform` confirmed via `git stash` to be
unaffected by this change)
- [x] `ruff check` / `ruff format --check` clean on all changed files
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] 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
- [ ] Introduces new feature or API
- [ ] Removes existing 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: [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]