-
Notifications
You must be signed in to change notification settings - Fork 160
Description
Motivation
When database errors occur in Superset (e.g., permission denied, table not found, connection failures), users see raw database exception messages that can be cryptic, technical, and unhelpful.
A configurable system for transforming raw database errors into user-friendly messages would allow Superset administrators to customize error messages per database connection. This improves the user experience, reduces support burden, and allows organizations to provide context-specific guidance when database errors occur.
Current Behavior
When database errors occur in Superset (such as in SQL Lab or when loading charts), users see the raw exception message from the database engine. These messages are displayed as-is without any customization options.
Reproduction Steps:
- Navigate to SQL Lab in Superset
- Connect to any database (e.g., the "examples" database)
- Execute a query that will fail:
SELECT * FROM non_existing_table - Observe that the error message is the raw database exception with no customization options
Expected Behavior
Superset should provide a configuration system (CUSTOM_DATABASE_ERRORS) that allows administrators to define custom error messages for specific database errors. The system should:
- Match database errors using regex patterns
- Replace error messages with custom, user-friendly text
- Support regex capture groups for dynamic message interpolation
- Provide an option to hide the default "See more" button with technical issue codes
- Work across all database error contexts (SQL Lab, chart loading, database validation)
- Support per-database configuration (different messages for different database connections)
Acceptance Criteria:
- A
CUSTOM_DATABASE_ERRORSconfiguration can be defined insuperset_config.pyor a dedicated configuration file - Custom error messages are displayed instead of raw database exceptions when a regex pattern matches
- The "See more" button with issue codes can be hidden when
show_issue_infois set toFalse - The configuration supports regex capture groups for dynamic message content
- The system works for errors in SQL Lab, chart execution, and database connection validation
- All existing tests pass and new tests cover the custom error functionality
Steps To Test
- Add a custom error configuration to your
superset_config.py:
import re
from flask_babel import gettext as __
from superset.errors import SupersetErrorType
CUSTOM_DATABASE_ERRORS = {
"examples": {
re.compile("no such table"): (
__("The table you're trying to access doesn't exist"),
SupersetErrorType.GENERIC_DB_ENGINE_ERROR,
{
"custom_doc_links": [
{
"url": "https://example.com/docs/tables",
"label": "View available tables"
}
],
"show_issue_info": False,
}
)
}
}- Restart Superset to load the new configuration
- In SQL Lab, execute:
SELECT * FROM non_existing_table - Verify the custom error message appears instead of the raw database error
- Verify the "See more" button with issue codes is NOT displayed
- Test with
show_issue_info: Trueand verify the "See more" button appears - Test with a pattern using capture groups to verify dynamic message interpolation
Submission
Download https://cap.so/ to record your screen (use Studio mode). Export as an mp4, and drag and drop into an issue comment below.
Guide to submitting pull requests: https://hackmd.io/@timothy1ee/Hky8kV3hlx