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:
parent
ef41c71701
commit
e13a3ca800
2 changed files with 17 additions and 10 deletions
|
|
@ -1689,8 +1689,9 @@ class Graph:
|
||||||
t.cancel()
|
t.cancel()
|
||||||
raise result
|
raise result
|
||||||
if isinstance(result, VertexBuildResult):
|
if isinstance(result, VertexBuildResult):
|
||||||
|
if self.flow_id is not None:
|
||||||
await log_vertex_build(
|
await log_vertex_build(
|
||||||
flow_id=self.flow_id or "",
|
flow_id=self.flow_id,
|
||||||
vertex_id=result.vertex.id,
|
vertex_id=result.vertex.id,
|
||||||
valid=result.valid,
|
valid=result.valid,
|
||||||
params=result.params,
|
params=result.params,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue