fix: Ensure flow_id is not None before logging vertex build details (#8954)

* fix: Update log_vertex_build to accept UUID for flow_id and improve error handling

* Changed flow_id type from str to str | UUID for better type safety.
* Added error handling to raise a ValueError if flow_id is invalid, enhancing robustness of the logging function.

* fix: Ensure flow_id is not None before logging vertex build details

* Updated log_vertex_build call to check if flow_id is not None, enhancing robustness and preventing potential errors when flow_id is absent.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-07-09 16:17:50 -03:00 committed by GitHub
commit e13a3ca800
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 10 deletions

View file

@ -1689,14 +1689,15 @@ class Graph:
t.cancel()
raise result
if isinstance(result, VertexBuildResult):
await log_vertex_build(
flow_id=self.flow_id or "",
vertex_id=result.vertex.id,
valid=result.valid,
params=result.params,
data=result.result_dict,
artifacts=result.artifacts,
)
if self.flow_id is not None:
await log_vertex_build(
flow_id=self.flow_id,
vertex_id=result.vertex.id,
valid=result.valid,
params=result.params,
data=result.result_dict,
artifacts=result.artifacts,
)
vertices.append(result.vertex)
else:

View file

@ -166,7 +166,7 @@ async def log_transaction(
async def log_vertex_build(
*,
flow_id: str,
flow_id: str | UUID,
vertex_id: str,
valid: bool,
params: Any,
@ -181,9 +181,15 @@ async def log_vertex_build(
try:
if not get_settings_service().settings.vertex_builds_storage_enabled:
return
try:
if isinstance(flow_id, str):
flow_id = UUID(flow_id)
except ValueError:
msg = f"Invalid flow_id passed to log_vertex_build: {flow_id!r}(type: {type(flow_id)})"
raise ValueError(msg) from None
vertex_build = VertexBuildBase(
flow_id=flow_id if isinstance(flow_id, UUID) else UUID(flow_id),
flow_id=flow_id,
id=vertex_id,
valid=valid,
params=str(params) if params else None,