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:
Amin Ghadersohi
2026-05-20 23:14:47 +00:00
parent 16ac2d9173
commit ad36aff3f9

View File

@@ -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)