Simplify execution_metadata
Handling for WorkflowNodeExecution
(#20062)
Currently, `WorkflowNodeExecution.execution_metadata_dict` returns `None` when metadata is absent in the database. This requires all callers to perform `None` checks when processing metadata, leading to more complex caller-side logic. This pull request updates the `execution_metadata_dict` method to return an empty dictionary instead of `None` when metadata is absent. This change would simplify the caller logic, as it removes the need for explicit `None` checks and provides a more consistent data structure to work with.
This commit is contained in:
@@ -666,8 +666,11 @@ class WorkflowNodeExecution(Base):
|
||||
return json.loads(self.process_data) if self.process_data else None
|
||||
|
||||
@property
|
||||
def execution_metadata_dict(self) -> dict[str, Any] | None:
|
||||
return json.loads(self.execution_metadata) if self.execution_metadata else None
|
||||
def execution_metadata_dict(self) -> dict[str, Any]:
|
||||
# When the metadata is unset, we return an empty dictionary instead of `None`.
|
||||
# This approach streamlines the logic for the caller, making it easier to handle
|
||||
# cases where metadata is absent.
|
||||
return json.loads(self.execution_metadata) if self.execution_metadata else {}
|
||||
|
||||
@property
|
||||
def extras(self):
|
||||
|
Reference in New Issue
Block a user