From 1fa9385d02f442a94ae143fd9c1c92248b37b444 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Thu, 30 Oct 2025 11:52:06 +0800 Subject: [PATCH] fix: resolve UUID JSON serialization error in checkpoint creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: - Object of type is not JSON serializable error when creating checkpoints - UUID objects in database records couldn't be serialized to JSON Solution: - Updated json_serializer function in create_checkpoint() to properly handle UUID types - Added explicit isinstance check for uuid.UUID before checking for isoformat - Ensures all UUID values are converted to strings before JSON serialization This ensures checkpoints can be created successfully with all database data types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- data/checkpoints/checkpoint_20251030_115009.json | 8 ++++++++ lawrisk/services/licensing_repo.py | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 data/checkpoints/checkpoint_20251030_115009.json diff --git a/data/checkpoints/checkpoint_20251030_115009.json b/data/checkpoints/checkpoint_20251030_115009.json new file mode 100644 index 0000000..1ab66b0 --- /dev/null +++ b/data/checkpoints/checkpoint_20251030_115009.json @@ -0,0 +1,8 @@ +{ + "checkpoint_id": "checkpoint_20251030_115009", + "timestamp": "20251030_115009", + "description": "1", + "tables": { + "business_scopes": [ + { + "id": \ No newline at end of file diff --git a/lawrisk/services/licensing_repo.py b/lawrisk/services/licensing_repo.py index f40a4ec..66b3c25 100644 --- a/lawrisk/services/licensing_repo.py +++ b/lawrisk/services/licensing_repo.py @@ -438,7 +438,14 @@ def create_checkpoint(description: str = "") -> Dict[str, Any]: def json_serializer(obj): """Convert non-JSON serializable objects to strings.""" - if hasattr(obj, 'isoformat'): # UUID, datetime, etc. + try: + import uuid + if isinstance(obj, uuid.UUID): + return str(obj) + except ImportError: + pass + + if hasattr(obj, 'isoformat'): return str(obj) raise TypeError(f"Object of type {type(obj)} is not JSON serializable")