fix(mcp): batch fix for execute_sql crashes, null timestamps, and deck.gl errors (#38977)

This commit is contained in:
Amin Ghadersohi
2026-03-31 18:50:20 +02:00
committed by GitHub
parent c37a3ec292
commit daefedebcd
10 changed files with 92 additions and 27 deletions

View File

@@ -36,8 +36,7 @@ from superset_core.queries.types import (
QueryStatus,
)
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import SupersetErrorException, SupersetSecurityException
from superset.errors import SupersetErrorType
from superset.extensions import event_logger
from superset.mcp_service.sql_lab.schemas import (
ColumnInfo,
@@ -91,21 +90,23 @@ async def execute_sql(request: ExecuteSqlRequest, ctx: Context) -> ExecuteSqlRes
db.session.query(Database).filter_by(id=request.database_id).first()
)
if not database:
raise SupersetErrorException(
SupersetError(
message=f"Database with ID {request.database_id} not found",
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR,
level=ErrorLevel.ERROR,
)
await ctx.error(
"Database not found: database_id=%s" % request.database_id
)
return ExecuteSqlResponse(
success=False,
error=f"Database with ID {request.database_id} not found",
error_type=SupersetErrorType.DATABASE_NOT_FOUND_ERROR.value,
)
if not security_manager.can_access_database(database):
raise SupersetSecurityException(
SupersetError(
message=(f"Access denied to database {database.database_name}"),
error_type=SupersetErrorType.DATABASE_SECURITY_ACCESS_ERROR,
level=ErrorLevel.ERROR,
)
await ctx.error(
"Access denied to database: %s" % database.database_name
)
return ExecuteSqlResponse(
success=False,
error=f"Access denied to database {database.database_name}",
error_type=SupersetErrorType.DATABASE_SECURITY_ACCESS_ERROR.value,
)
# 2. Build QueryOptions and execute query