aminghadersohi opened a new pull request, #41919:
URL: https://github.com/apache/superset/pull/41919

   ## SUMMARY
   `update_dashboard`'s `_find_and_authorize_dashboard` helper caught 
`DashboardNotFoundError` and `SQLAlchemyError` in the same `except` clause, 
returning a `DashboardNotFound` response for both. A real 
database/infrastructure failure during the dashboard lookup was therefore 
misreported to the caller as "dashboard not found," with zero server-side 
logging of the underlying error — invisible to operators and misleading to the 
MCP client.
   
   This splits the handling:
   - `DashboardNotFoundError` still returns the existing `DashboardNotFound` 
structured error.
   - `SQLAlchemyError` is now logged server-side via `logger.exception` and 
returns a distinct `DatabaseError` with a generic message. The raw exception 
text is never included in the response, since `str(exc)` on a `SQLAlchemyError` 
can leak table/column/constraint names — same leak-avoidance pattern already 
used in `generate_dashboard.py`.
   
   Audited the rest of the dashboard domain 
(`add_chart_to_existing_dashboard.py`, `remove_chart_from_dashboard.py`, 
`duplicate_dashboard.py`, `manage_native_filters.py`) and the wider 
`mcp_service` package for the same "SQLAlchemyError collapsed into not-found" 
pattern; no other occurrence exists.
   
   ## BEFORE/AFTER
   **Before:** A transient DB error during `update_dashboard`'s lookup returned 
`{"error": "Dashboard not found: ...", "error_type": "DashboardNotFound"}` with 
no log line anywhere.
   
   **After:** The same failure returns `{"error": "Failed to look up dashboard 
due to a database error.", "error_type": "DatabaseError"}` and is logged 
server-side via `logger.exception` (with traceback) for observability.
   
   ## TESTING INSTRUCTIONS
   - `pytest 
tests/unit_tests/mcp_service/dashboard/tool/test_update_dashboard.py -q` — 15 
passed, including a new test asserting the DB-error path returns 
`error_type="DatabaseError"`, never leaks the raw exception text, and calls 
`logger.exception`.
   - `pytest tests/unit_tests/mcp_service/dashboard/ -q` — 265 passed (no 
regressions).
   
   ## ADDITIONAL INFORMATION
   - [x] Has associated tests


-- 
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]

Reply via email to