deeshantk opened a new issue, #36116:
URL: https://github.com/apache/superset/issues/36116

   ## [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.


-- 
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]

Reply via email to