This is an automated email from the ASF dual-hosted git repository. kasiazjc pushed a commit to branch fix/column-select-saved-tab-label in repository https://gitbox.apache.org/repos/asf/superset.git
commit 4685d8824325b363acce5c9675c5f9e460d8e350 Author: Amin Ghadersohi <[email protected]> AuthorDate: Fri May 15 01:47:29 2026 +0000 fix(mcp): address review comments on create_dataset tool - Use public get_list_classnames() instead of private _exceptions attribute to identify wrapped validation errors in DatasetInvalidError. - Add table_name whitespace validator to CreateDatasetRequest, matching the pattern in CreateVirtualDatasetRequest. --- superset/mcp_service/dataset/schemas.py | 7 +++++++ superset/mcp_service/dataset/tool/create_dataset.py | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/superset/mcp_service/dataset/schemas.py b/superset/mcp_service/dataset/schemas.py index 26d598b7e9e..b4ea4c9c845 100644 --- a/superset/mcp_service/dataset/schemas.py +++ b/superset/mcp_service/dataset/schemas.py @@ -361,6 +361,13 @@ class CreateDatasetRequest(BaseModel): ), ] + @field_validator("table_name") + @classmethod + def table_name_must_not_be_empty(cls, v: str) -> str: + if not v.strip(): + raise ValueError("table_name must not be empty") + return v.strip() + class CreateVirtualDatasetRequest(BaseModel): """Request schema for create_virtual_dataset.""" diff --git a/superset/mcp_service/dataset/tool/create_dataset.py b/superset/mcp_service/dataset/tool/create_dataset.py index 8396e5c0d98..0264ab56f3e 100644 --- a/superset/mcp_service/dataset/tool/create_dataset.py +++ b/superset/mcp_service/dataset/tool/create_dataset.py @@ -120,11 +120,13 @@ async def create_dataset( except DatasetInvalidError as exc: # CreateDatasetCommand.validate() aggregates individual validation errors - # into DatasetInvalidError; inspect them for specific error types. - if any(isinstance(e, DatasetExistsValidationError) for e in exc._exceptions): + # into DatasetInvalidError; use the public get_list_classnames() helper + # to identify which specific validation errors are present. + classnames = exc.get_list_classnames() + if DatasetExistsValidationError.__name__ in classnames: await ctx.warning("Dataset already exists: %s" % str(exc)) return DatasetError.create(error=str(exc), error_type="DatasetExistsError") - if any(isinstance(e, TableNotFoundValidationError) for e in exc._exceptions): + if TableNotFoundValidationError.__name__ in classnames: await ctx.warning("Table not found: %s" % str(exc)) return DatasetError.create(error=str(exc), error_type="TableNotFoundError") messages = exc.normalized_messages()
