mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Add error handling for JSON serialization failures
- Wrap json.dumps() in try-catch block to handle JSONEncodeError - Raise RuntimeError with descriptive message for serialization failures - Addresses PR review feedback for better fault tolerance Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -90,6 +90,7 @@ class SQLiteFlowPersistence(FlowPersistence):
|
||||
f"state_data must be either a Pydantic BaseModel or dict, got {type(state_data)}"
|
||||
)
|
||||
|
||||
try:
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -107,6 +108,8 @@ class SQLiteFlowPersistence(FlowPersistence):
|
||||
json.dumps(state_dict, cls=CrewJSONEncoder),
|
||||
),
|
||||
)
|
||||
except json.JSONEncodeError as e:
|
||||
raise RuntimeError(f"Failed to serialize flow state: {str(e)}") from e
|
||||
|
||||
def load_state(self, flow_uuid: str) -> Optional[Dict[str, Any]]:
|
||||
"""Load the most recent state for a given flow UUID.
|
||||
|
||||
Reference in New Issue
Block a user