rusackas opened a new pull request, #41295: URL: https://github.com/apache/superset/pull/41295
### SUMMARY `RoleRestAPI.get_list` (`/api/v1/security/roles/search/`) caught unexpected errors with a hand-written `except Exception` that returned `str(e)` directly in the HTTP 500 response body and made no logging call. This meant raw ORM/driver error text could surface to the caller, while the same error was invisible in the structured logging pipeline. This change: - Logs the exception server-side via `logger.exception(...)` so operators get the full detail and stack trace. - Returns a generic `"An unexpected error occurred"` message to the caller instead of the raw exception text. The endpoint remains gated behind `@protect()` / `list_roles`; this only changes what an unexpected-error response body contains and ensures the error is recorded. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A — backend error-handling behavior. ### TESTING INSTRUCTIONS Integration test added in `tests/integration_tests/security/api_tests.py` (`test_show_roles_unexpected_error_returns_generic_message`): - Forces an exception inside `get_list`. - Asserts the 500 body does not contain the raw exception detail, contains the generic message, and that `logger.exception` was called. Run: `pytest tests/integration_tests/security/api_tests.py -k unexpected_error` ### 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 - [ ] 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]
