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() t.cancel()
raise result raise result
if isinstance(result, VertexBuildResult): if isinstance(result, VertexBuildResult):
await log_vertex_build( if self.flow_id is not None:
flow_id=self.flow_id or "", await log_vertex_build(
vertex_id=result.vertex.id, flow_id=self.flow_id,
valid=result.valid, vertex_id=result.vertex.id,
params=result.params, valid=result.valid,
data=result.result_dict, params=result.params,
artifacts=result.artifacts, data=result.result_dict,
) artifacts=result.artifacts,
)
vertices.append(result.vertex) vertices.append(result.vertex)
else: else:

View file

@ -166,7 +166,7 @@ async def log_transaction(
async def log_vertex_build( async def log_vertex_build(
*, *,
flow_id: str, flow_id: str | UUID,
vertex_id: str, vertex_id: str,
valid: bool, valid: bool,
params: Any, params: Any,
@ -181,9 +181,15 @@ async def log_vertex_build(
try: try:
if not get_settings_service().settings.vertex_builds_storage_enabled: if not get_settings_service().settings.vertex_builds_storage_enabled:
return 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( vertex_build = VertexBuildBase(
flow_id=flow_id if isinstance(flow_id, UUID) else UUID(flow_id), flow_id=flow_id,
id=vertex_id, id=vertex_id,
valid=valid, valid=valid,
params=str(params) if params else None, params=str(params) if params else None,