fix: fixes date time issue, which was blocking run flow execution of agent flows (#5866)

* fixes PydanticSerializationError

fixes:
    PydanticSerializationError: Error calling function `serialize_model`: TypeError: tz_convert() takes exactly 2 positional arguments (1 given)

* format

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/api/v1/schemas.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Edwin Jose 2025-01-22 14:56:20 -05:00 committed by GitHub
commit 8108d6fc13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -287,7 +287,7 @@ class ResultDataResponse(BaseModel):
return f"{obj[:max_length]}... [truncated]"
return obj
if isinstance(obj, datetime):
return obj.astimezone().isoformat()
return obj.replace(tzinfo=timezone.utc).isoformat()
if isinstance(obj, Decimal):
return float(obj)
if isinstance(obj, UUID):

View file

@ -86,6 +86,9 @@ def serialize_field(value):
if hasattr(value, "to_json"):
return value.to_json()
return value.dict()
# Handle datetime objects
if hasattr(value, "isoformat"):
return value.isoformat()
return str(value)
@ -182,10 +185,10 @@ async def log_vertex_build(
id=vertex_id,
valid=valid,
params=str(params) if params else None,
# ugly hack to get the model dump with weird datatypes
data=json.loads(data.model_dump_json()),
# ugly hack to get the model dump with weird datatypes
artifacts=json.loads(json.dumps(artifacts, default=str)),
# Serialize data using our custom serializer
data=serialize_field(data),
# Serialize artifacts using our custom serializer
artifacts=serialize_field(artifacts) if artifacts else None,
)
async with session_getter(get_db_service()) as session:
inserted = await crud_log_vertex_build(session, vertex_build)