[SIP-191] Proposal for Improving Import Error Logging for Dashboard/Chart ZIP Imports
- Dominant language
- Python
- Stars
- 74.8k
- Forks
- 18.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 664
Description
## [SIP] Proposal for Improved Error Reporting During Dashboard/Chart Import Validation
### Motivation
Currently, when importing dashboards or charts using the Superset Import API, any validation failure or metadata mismatch inside the import bundle results in opaque error messages such as:
~~~
Import dashboard failed for an unknown reason
~~~
The server logs contain a generic stack trace like:
KeyError: 580
…but the API response and UI do not expose which part of the import bundle is invalid.
This makes it difficult to debug problems such as:
- Mismatched IDs in `filter_scopes`
- Missing chart references in dashboard metadata
- Broken or outdated metadata produced by older Superset versions
- Incorrect ZIP structure
Users must manually inspect YAML/JSON inside the ZIP—something that is error-prone and slow.
Improving the error messages will significantly reduce debugging time and make import flows more predictable for developers.
---
### Proposed Change
1. Add Proper Aggregated Validation Error Logging
The current code in `superset/commands/importers/v1/assets.py` catches a list of validation exceptions but logs almost nothing, emitting only:
Import dashboard failed for an unknown reason
This proposal introduces structured, explicit error logging for each validation exception.
### Proposed implementation
Below is a production-aligned rewrite of the snippet the author experimented with:
```python
# superset/commands/importers/v1/assets.py
import logging
logger = logging.getLogger(__name__)
if exceptions:
for exc in exceptions:
# Log each validation exception clearly with details
logger.error(
"Import validation error: %s | details: %s",
str(exc),
getattr(exc, "messages", None)
)
# Raise a domain-specific error containing the full list
raise CommandInvalidError(
"Error importing assets due to validation failures",
exceptions=exceptions,
)
```
Improvements over the experimental version
- Uses logger (Superset convention) instead of logging
- Clearer message formatting
- Includes both the exception itself and its .messages attribute (if any)
- Raises a more descriptive CommandInvalidError
- Matches the surrounding command architecture in other importers
## Return Descriptive Error Messages via API
Example API response:
~~~
{
"error": "ImportValidationError",
"errors": [
{
"message": "Chart ID 580 referenced in filter_scopes does not exist.",
"exception_type": "KeyError"
}
]
}
~~~
### New or Changed Public Interfaces
API Responses
Import-related endpoints will now return:
More detailed error messages
Structured lists of validation failures
This is backward compatible because:
The HTTP code remains the same
Existing clients that ignore details remain unaffected
CLI (superset import-*)
The CLI will print the same improved messages, giving developers immediate insight into metadata issues.
No CLI flags or config changes required.
### New dependencies
None
### Migration Plan and Compatibility
No migrations required.
### Rejected Alternatives
1. Only improving server logs, not API responses
Many users run imports in CI/CD pipelines or via automated scripts and do not have access to server logs.
Contributor guide
Research direction
Start in superset/commands/importers/v1/assets.py, reading the existing validation-exception handling and the surrounding importer command architecture. Trace how Superset Import API and superset import-* report failures; done means validation errors expose structured details for dashboard and chart imports without changing the HTTP status or requiring new dependencies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100