From 39af4ea2d52b5b2385183deeb5b3c782403a3c3d Mon Sep 17 00:00:00 2001 From: Daryl Lim Date: Thu, 28 Mar 2024 03:19:24 -0700 Subject: [PATCH] fix(engine): Eagerly serialize to json using pydantic to handle datetimes --- tracecat/runner/actions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tracecat/runner/actions.py b/tracecat/runner/actions.py index edcc152b..d55c9481 100644 --- a/tracecat/runner/actions.py +++ b/tracecat/runner/actions.py @@ -379,7 +379,8 @@ def _index_events( workflow_title=workflow_title, workflow_run_id=workflow_run_id, data={ - action_run_id: trail.output + # Explicitly serialize to json using pydantic to handle datetimes + action_run_id: trail.model_dump_json(include={"output"}) for action_run_id, trail in action_trail.items() }, published_at=datetime.now(UTC).replace(tzinfo=None), @@ -950,7 +951,9 @@ async def log_complete_action_run( async with AuthenticatedAPIClient(http2=True) as client: response = await client.post( f"/actions/{action_id}/runs/{action_run.id}", - json=params.model_dump(), + # Explicitly serialize to json using pydantic to handle datetimes + content=params.model_dump_json(), + headers={"Content-Type": "application/json"}, ) if response.status_code != 204: logger.error(