GitHub user dosubot[bot] added a comment to the discussion: Show friendly error when Superset unable to connect to backing database
<!-- Answer --> Unfortunately, there is **no built-in `superset_config.py` setting** that suppresses raw database error messages on dashboards. The `SHOW_STACKTRACE = False` setting (which is the default) only hides the Python traceback — the raw database error text (host, port, user details) still gets passed through to users [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/config.py#L284-L287) . The reason the monkey-patching approach may not have worked is that the error message likely doesn't match the regex pattern exactly, or the error is being surfaced through a different code path (e.g., `error_msg_from_exception()` extracts the full text before `extract_errors()` can intercept it) [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/core.py#L419-L439). **What you can try via `superset_config.py`:** Use `FLASK_APP_MUTATOR` to patch the `error_msg_from_exception` utility itself, which is the function that extracts and returns the raw error text to the frontend: ```python # superset_config.py import re def FLASK_APP_MUTATOR(app): from superset import utils from superset.utils import core as utils_core _original_error_msg = utils_core.error_msg_from_exception def sanitized_error_msg(ex): msg = _original_error_msg(ex) # If it looks like a connection error, replace with generic message if re.search(r"(connection to server|OperationalError|password authentication failed)", str(msg), re.IGNORECASE): return "Unable to connect to the database. Please reach out to the Chart Owner for assistance." return msg utils_core.error_msg_from_exception = sanitized_error_msg ``` This patches the function at the point where error messages are extracted, before they're sent to the frontend [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/core.py#L419-L439). However, be aware that this approach has a caveat: depending on the import order, some modules may have already imported the original function reference directly. **Bottom line:** Superset doesn't currently offer a simple on/off config to hide raw DB errors from dashboards. Achieving this cleanly would require either: 1. The monkey-patching approach above (best effort from config) 2. A custom frontend build that overrides the `DatabaseErrorMessage` component to display only a generic message [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx#L35-L45) [[4]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/setup/setupErrorMessages.ts#L49-L60) 3. A code change to the Superset source to add a dedicated config option for this This might be worth raising as a feature request — a config like `SANITIZE_DB_ERRORS = True` would be a useful security option for production deployments. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=653835eb-f591-4e51-95f3-da386cc7fbf8) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) GitHub link: https://github.com/apache/superset/discussions/40881#discussioncomment-17249313 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
