jesperct commented on code in PR #40376:
URL: https://github.com/apache/superset/pull/40376#discussion_r3310771684


##########
superset/commands/dataset/importers/v1/__init__.py:
##########
@@ -69,4 +73,11 @@ def _import(
                 and config["database_uuid"] in database_ids
             ):
                 config["database_id"] = database_ids[config["database_uuid"]]
-                import_dataset(config, overwrite=overwrite)
+                try:
+                    import_dataset(config, overwrite=overwrite)
+                except MultiCatalogDisabledValidationError as ex:
+                    # surface as a 422 validation error instead of a generic 
500
+                    raise CommandInvalidError(
+                        "; ".join(str(message) for message in ex.messages),

Review Comment:
   @msyavuz this CWE-20 flag is a false positive. 
`MultiCatalogDisabledValidationError` is initialized with a list, so 
`ex.messages` is `['Only the default catalog is supported for this 
connection']`, not a dict. The `{"catalog": [...]}` shape only appears via 
`ex.normalized_messages()`. The existing 
`test_import_command_surfaces_non_default_catalog_as_validation_error` already 
asserts the message text on the raised `CommandInvalidError` and passes, so the 
422 payload is correct as-is.



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