{"record":{"id":"614eed0f949facc5","repo":"apache/superset","slug":"join-str-message-for-message-in-ex-messages","errorCode":null,"errorMessage":"; \".join(str(message) for message in ex.messages)","messagePattern":"; \"\\.join\\(str\\(message\\) for message in ex\\.messages\\)","errorType":"validation","errorClass":"CommandInvalidError","httpStatus":422,"severity":"error","filePath":"superset/commands/dataset/importers/v1/__init__.py","lineNumber":80,"sourceCode":"        # import related databases\n        database_ids: dict[str, int] = {}\n        for file_name, config in configs.items():\n            if file_name.startswith(\"databases/\") and config[\"uuid\"] in database_uuids:\n                database = import_database(config, overwrite=False)\n                database_ids[str(database.uuid)] = database.id\n\n        # import datasets with the correct parent ref\n        for file_name, config in configs.items():\n            if (\n                file_name.startswith(\"datasets/\")\n                and config[\"database_uuid\"] in database_ids\n            ):\n                config[\"database_id\"] = database_ids[config[\"database_uuid\"]]\n                try:\n                    import_dataset(config, overwrite=overwrite)\n                except MultiCatalogDisabledValidationError as ex:\n                    # surface as a 422 validation error instead of a generic 500\n                    raise CommandInvalidError(\n                        \"; \".join(str(message) for message in ex.messages),\n                        [ex],\n                    ) from ex\n","sourceCodeStart":62,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/importers/v1/__init__.py#L62-L84","documentation":"When a v1 dataset import assigns a dataset a non-default catalog while the target database has multi-catalog support disabled, the underlying MultiCatalogDisabledValidationError is re-raised as CommandInvalidError so the REST layer returns 422 (validation error) instead of a generic 500. The message is the joined validation messages from the original exception.","triggerScenarios":"POST/PUT to /api/v1/dataset/import (or dashboard import that includes datasets) with a bundle where a dataset's config has a 'catalog' value different from the database's default catalog, and the database's engine spec has allow_multi_catalog disabled (or the engine does not support catalogs at all with a set default).","commonSituations":"Exporting a dataset from a multi-catalog engine (e.g. Trino, Spark with catalogs) and importing it into a deployment where the connection string pins a single catalog; feature flag or engine-spec differences between source and target instances.","solutions":["Remove or set the 'catalog' field to the target database's default catalog in the uploaded YAML","Enable multi-catalog on the target connection if the engine supports it (update the SQLAlchemy URI / engine settings so allow_multi_catalog is true)","Import into a database connection whose default catalog matches the dataset's catalog"],"exampleFix":"# before (exported YAML)\ncatalog: hive\n# after (match target default catalog)\ncatalog: default\n# or omit the key entirely","handlingStrategy":"try-catch","validationCode":"from superset.commands.dataset.importers.v1.utils import validate_catalog\n\nfor cfg in dataset_configs:  # before import, pre-flight each dataset config\n    if cfg.get('catalog'):\n        db = session.query(Database).filter_by(id=cfg['database_id']).first()\n        if db and (default := db.get_default_catalog()) is not None:\\\n           not db.allow_multi_catalog and cfg['catalog'] != default:\n            cfg['catalog'] = default  # normalize to the target default\n# then run the import","typeGuard":null,"tryCatchPattern":"from superset.commands.exceptions import CommandInvalidError\ntry:\n    client.post('/api/v1/dataset/import/', files=...)\nexcept CommandInvalidError as ex:\n    # 422-class error; ex.messages lists per-config issues — fix YAML and retry once\n    ...","preventionTips":["Normalize or strip the 'catalog' field when exporting bundles meant for single-catalog targets","Keep source and target connection catalogs aligned, or document the default catalog of each target connection","Pre-flight each dataset config with validate_catalog before uploading"],"tags":["dataset-import","catalog","validation","multi-catalog","superset"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}