mirror of
https://github.com/apache/superset.git
synced 2026-05-15 21:05:14 +00:00
Compare commits
2 Commits
fix/mcp-li
...
fix/mcp-ex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16d136ef8d | ||
|
|
c78658d852 |
@@ -199,8 +199,12 @@ async def get_chart_data( # noqa: C901
|
|||||||
|
|
||||||
if not chart:
|
if not chart:
|
||||||
await ctx.warning("Chart not found: identifier=%s" % (request.identifier,))
|
await ctx.warning("Chart not found: identifier=%s" % (request.identifier,))
|
||||||
|
safe_id = str(request.identifier)[:200]
|
||||||
return ChartError(
|
return ChartError(
|
||||||
error=f"No chart found with identifier: {request.identifier}",
|
error=(
|
||||||
|
f"No chart found with identifier: {safe_id}."
|
||||||
|
" Use list_charts to get valid chart IDs."
|
||||||
|
),
|
||||||
error_type="NotFound",
|
error_type="NotFound",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1192,8 +1192,22 @@ async def _get_chart_preview_internal( # noqa: C901
|
|||||||
|
|
||||||
if not chart:
|
if not chart:
|
||||||
await ctx.warning("Chart not found: identifier=%s" % (request.identifier,))
|
await ctx.warning("Chart not found: identifier=%s" % (request.identifier,))
|
||||||
|
safe_id = str(request.identifier)[:200]
|
||||||
|
is_form_data_key = (
|
||||||
|
isinstance(request.identifier, str)
|
||||||
|
and len(request.identifier) > 8
|
||||||
|
and not request.identifier.isdigit()
|
||||||
|
)
|
||||||
|
if is_form_data_key:
|
||||||
|
recovery = (
|
||||||
|
"If using a form_data_key, it may have expired — "
|
||||||
|
"use generate_explore_link to get a fresh key, "
|
||||||
|
"or use list_charts to find a saved chart by ID."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
recovery = "Use list_charts to get valid chart IDs."
|
||||||
return ChartError(
|
return ChartError(
|
||||||
error=f"No chart found with identifier: {request.identifier}",
|
error=f"No chart found with identifier: {safe_id}. {recovery}",
|
||||||
error_type="NotFound",
|
error_type="NotFound",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -337,17 +337,18 @@ async def update_chart( # noqa: C901
|
|||||||
chart = find_chart_by_identifier(request.identifier)
|
chart = find_chart_by_identifier(request.identifier)
|
||||||
|
|
||||||
if not chart:
|
if not chart:
|
||||||
|
safe_id = str(request.identifier)[:200]
|
||||||
|
not_found_msg = (
|
||||||
|
f"No chart found with identifier: {safe_id}."
|
||||||
|
" Use list_charts to get valid chart IDs."
|
||||||
|
)
|
||||||
return GenerateChartResponse.model_validate(
|
return GenerateChartResponse.model_validate(
|
||||||
{
|
{
|
||||||
"chart": None,
|
"chart": None,
|
||||||
"error": {
|
"error": {
|
||||||
"error_type": "NotFound",
|
"error_type": "NotFound",
|
||||||
"message": (
|
"message": not_found_msg,
|
||||||
f"No chart found with identifier: {request.identifier}"
|
"details": not_found_msg,
|
||||||
),
|
|
||||||
"details": (
|
|
||||||
f"No chart found with identifier: {request.identifier}"
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
"success": False,
|
"success": False,
|
||||||
"schema_version": "2.0",
|
"schema_version": "2.0",
|
||||||
|
|||||||
@@ -334,7 +334,10 @@ def _find_and_authorize_dashboard(
|
|||||||
dashboard=None,
|
dashboard=None,
|
||||||
dashboard_url=None,
|
dashboard_url=None,
|
||||||
position=None,
|
position=None,
|
||||||
error=f"Dashboard with ID {dashboard_id} not found",
|
error=(
|
||||||
|
f"Dashboard with ID {dashboard_id} not found."
|
||||||
|
" Use list_dashboards to get valid dashboard IDs."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -392,7 +395,10 @@ def add_chart_to_existing_dashboard(
|
|||||||
dashboard=None,
|
dashboard=None,
|
||||||
dashboard_url=None,
|
dashboard_url=None,
|
||||||
position=None,
|
position=None,
|
||||||
error=f"Chart with ID {request.chart_id} not found",
|
error=(
|
||||||
|
f"Chart with ID {request.chart_id} not found."
|
||||||
|
" Use list_charts to get valid chart IDs."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate dataset access for the chart.
|
# Validate dataset access for the chart.
|
||||||
|
|||||||
@@ -230,7 +230,10 @@ def generate_dashboard( # noqa: C901
|
|||||||
return GenerateDashboardResponse(
|
return GenerateDashboardResponse(
|
||||||
dashboard=None,
|
dashboard=None,
|
||||||
dashboard_url=None,
|
dashboard_url=None,
|
||||||
error=f"Charts not found: {list(missing_chart_ids)}",
|
error=(
|
||||||
|
f"Charts not found: {list(missing_chart_ids)}."
|
||||||
|
" Use list_charts to get valid chart IDs."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate dataset access for each chart.
|
# Validate dataset access for each chart.
|
||||||
|
|||||||
@@ -183,7 +183,10 @@ async def query_dataset( # noqa: C901
|
|||||||
if dataset is None:
|
if dataset is None:
|
||||||
await ctx.error("Dataset not found: identifier=%s" % (request.dataset_id,))
|
await ctx.error("Dataset not found: identifier=%s" % (request.dataset_id,))
|
||||||
return DatasetError.create(
|
return DatasetError.create(
|
||||||
error=f"No dataset found with identifier: {request.dataset_id}",
|
error=(
|
||||||
|
f"No dataset found with identifier: {request.dataset_id}."
|
||||||
|
" Use list_datasets to get valid dataset IDs."
|
||||||
|
),
|
||||||
error_type="NotFound",
|
error_type="NotFound",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,10 @@ async def execute_sql(request: ExecuteSqlRequest, ctx: Context) -> ExecuteSqlRes
|
|||||||
)
|
)
|
||||||
return ExecuteSqlResponse(
|
return ExecuteSqlResponse(
|
||||||
success=False,
|
success=False,
|
||||||
error=f"Database with ID {request.database_id} not found",
|
error=(
|
||||||
|
f"Database with ID {request.database_id} not found."
|
||||||
|
" Use list_databases to get valid database IDs."
|
||||||
|
),
|
||||||
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR.value,
|
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ def open_sql_lab_with_context(
|
|||||||
database = DatabaseDAO.find_by_id(request.database_connection_id)
|
database = DatabaseDAO.find_by_id(request.database_connection_id)
|
||||||
if not database:
|
if not database:
|
||||||
error_message = (
|
error_message = (
|
||||||
f"Database with ID {request.database_connection_id} not found"
|
f"Database with ID {request.database_connection_id} not found."
|
||||||
|
" Use list_databases to get valid database IDs."
|
||||||
)
|
)
|
||||||
return _sanitize_sql_lab_response_for_llm_context(
|
return _sanitize_sql_lab_response_for_llm_context(
|
||||||
SqlLabResponse(
|
SqlLabResponse(
|
||||||
|
|||||||
@@ -298,7 +298,8 @@ class TestOpenSqlLabWithContext:
|
|||||||
field_path=("title",),
|
field_path=("title",),
|
||||||
)
|
)
|
||||||
assert response.error == sanitize_for_llm_context(
|
assert response.error == sanitize_for_llm_context(
|
||||||
"Database with ID 404 not found",
|
"Database with ID 404 not found."
|
||||||
|
" Use list_databases to get valid database IDs.",
|
||||||
field_path=("error",),
|
field_path=("error",),
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user