mirror of
https://github.com/apache/superset.git
synced 2026-05-21 15:55:10 +00:00
fix(mcp): convert dttm cutoff to ISO string so filters_applied validates
The injected 7-day default filter used a datetime object as the value, but ActionLogFilter.value only allows str|int|float|bool|list. Pydantic rejects the datetime when building the filters_applied list in ActionLogList, causing a ValidationError on every call that triggered the default filter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,16 +90,14 @@ async def list_action_logs(
|
||||
filters: list[ColumnOperator] = list(request.filters)
|
||||
has_dttm_filter = any(getattr(f, "col", None) == "dttm" for f in filters)
|
||||
if not has_dttm_filter:
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=7)
|
||||
cutoff = (datetime.now(timezone.utc) - timedelta(days=7)).isoformat()
|
||||
default_filter = ColumnOperator(
|
||||
col="dttm",
|
||||
opr=ColumnOperatorEnum.gte,
|
||||
value=cutoff,
|
||||
)
|
||||
filters = [default_filter] + filters
|
||||
await ctx.debug(
|
||||
"Applied default 7-day dttm filter: cutoff=%s" % (cutoff.isoformat(),)
|
||||
)
|
||||
await ctx.debug("Applied default 7-day dttm filter: cutoff=%s" % (cutoff,))
|
||||
|
||||
def _serialize(obj: object, cols: list[str] | None) -> ActionLogInfo | None:
|
||||
return serialize_action_log_object(obj)
|
||||
|
||||
Reference in New Issue
Block a user