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:
@@ -32,7 +32,7 @@ if TYPE_CHECKING:
|
||||
|
||||
from superset.commands.exceptions import CommandException
|
||||
from superset.commands.explore.form_data.parameters import CommandParameters
|
||||
from superset.exceptions import SupersetException
|
||||
from superset.exceptions import OAuth2Error, OAuth2RedirectError, SupersetException
|
||||
from superset.extensions import event_logger
|
||||
from superset.mcp_service.chart.chart_utils import validate_chart_dataset
|
||||
from superset.mcp_service.chart.schemas import (
|
||||
@@ -43,6 +43,10 @@ from superset.mcp_service.chart.schemas import (
|
||||
PerformanceMetadata,
|
||||
)
|
||||
from superset.mcp_service.utils.cache_utils import get_cache_status_from_result
|
||||
from superset.mcp_service.utils.oauth2_utils import (
|
||||
build_oauth2_redirect_message,
|
||||
OAUTH2_CONFIG_ERROR_MESSAGE,
|
||||
)
|
||||
from superset.utils.core import merge_extra_filters
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -797,6 +801,23 @@ async def get_chart_data( # noqa: C901
|
||||
error_type="DataError",
|
||||
)
|
||||
|
||||
except OAuth2RedirectError as ex:
|
||||
await ctx.error(
|
||||
"Chart data requires OAuth authentication: identifier=%s"
|
||||
% request.identifier
|
||||
)
|
||||
return ChartError(
|
||||
error=build_oauth2_redirect_message(ex),
|
||||
error_type="OAUTH2_REDIRECT",
|
||||
)
|
||||
except OAuth2Error:
|
||||
await ctx.error(
|
||||
"OAuth2 configuration error: identifier=%s" % request.identifier
|
||||
)
|
||||
return ChartError(
|
||||
error=OAUTH2_CONFIG_ERROR_MESSAGE,
|
||||
error_type="OAUTH2_REDIRECT_ERROR",
|
||||
)
|
||||
except Exception as e:
|
||||
await ctx.error(
|
||||
"Chart data retrieval failed: identifier=%s, error=%s, error_type=%s"
|
||||
|
||||
Reference in New Issue
Block a user