mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(mcp): handle OAuth-authenticated databases in execute_sql (#39166)
This commit is contained in:
@@ -26,6 +26,7 @@ from typing import Any, Dict
|
||||
from fastmcp import Context
|
||||
from superset_core.mcp.decorators import tool, ToolAnnotations
|
||||
|
||||
from superset.exceptions import OAuth2Error, OAuth2RedirectError
|
||||
from superset.extensions import event_logger
|
||||
from superset.mcp_service.chart.chart_utils import (
|
||||
analyze_chart_capabilities,
|
||||
@@ -40,6 +41,10 @@ from superset.mcp_service.chart.schemas import (
|
||||
PerformanceMetadata,
|
||||
UpdateChartPreviewRequest,
|
||||
)
|
||||
from superset.mcp_service.utils.oauth2_utils import (
|
||||
build_oauth2_redirect_message,
|
||||
OAUTH2_CONFIG_ERROR_MESSAGE,
|
||||
)
|
||||
from superset.utils import json as utils_json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -175,6 +180,25 @@ def update_chart_preview(
|
||||
}
|
||||
return result
|
||||
|
||||
except OAuth2RedirectError as ex:
|
||||
logger.warning(
|
||||
"Chart preview update requires OAuth authentication: form_data_key=%s",
|
||||
request.form_data_key,
|
||||
)
|
||||
return {
|
||||
"chart": None,
|
||||
"error": build_oauth2_redirect_message(ex),
|
||||
"success": False,
|
||||
}
|
||||
except OAuth2Error:
|
||||
logger.warning(
|
||||
"OAuth2 configuration error: form_data_key=%s", request.form_data_key
|
||||
)
|
||||
return {
|
||||
"chart": None,
|
||||
"error": OAUTH2_CONFIG_ERROR_MESSAGE,
|
||||
"success": False,
|
||||
}
|
||||
except Exception as e:
|
||||
execution_time = int((time.time() - start_time) * 1000)
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user