Show friendly error when Superset unable to connect to backing database #40881
Replies: 1 comment 6 replies
-
|
Superset already has a built-in mechanism for transforming raw database errors into user-friendly messages — it's the Here's how the system works and how you can customize it: How it works: When a chart query fails, Why you might still see raw errors: If the specific error string from your psycopg2 driver doesn't match any of the existing regex patterns, the system falls back to To wrap connection errors in a friendlier message, you can extend the PostgreSQL engine spec's # Add a pattern that catches the "password authentication failed" error
CONNECTION_INVALID_PASSWORD_REGEX = re.compile(
r'connection to server .+ failed: FATAL:\s+password authentication failed for user'
)
# Then in the custom_errors dict:
custom_errors = {
CONNECTION_INVALID_PASSWORD_REGEX: (
__("Unable to connect to the database. Please contact your administrator."),
SupersetErrorType.CONNECTION_INVALID_PASSWORD_ERROR,
{"invalid": ["password"]},
),
# ... other patterns
}This approach lets you:
If you want a broader catch-all for any connection failure (not just password errors), you could add a more general regex pattern that matches the Note that Superset also has password masking for SQLAlchemy URIs that appear in error metadata [4], but that's separate from the chart-facing error messages you're asking about. To reply, just mention @dosu. Docs are dead. Just use Dosu. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @dosu,
How to wrap the actual error in a friendly message when connection to backing database fails?
Current error in charts:
I would like to wrap this error into a Network error or Bad Gateway error without disclosing the database host/port/user details.
Beta Was this translation helpful? Give feedback.
All reactions