Skip to content

Commit 193c596

Browse files
committed
feat: Add debug logging for file_path conflict resolution
Added debug logging when resolving file_path conflicts in upsert_entity to track how often the conflict resolution path is hit in production. This will help with monitoring and debugging sync operations. Logs entity_id, file_path, and observation count when merge is used. Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 42abc53 commit 193c596

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/basic_memory/repository/entity_repository.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
from typing import List, Optional, Sequence, Union
55

6+
from loguru import logger
67
from sqlalchemy import select
78
from sqlalchemy.exc import IntegrityError
89
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
@@ -163,6 +164,10 @@ async def upsert_entity(self, entity: Entity) -> Entity:
163164

164165
if existing_entity:
165166
# File path conflict - update the existing entity
167+
logger.debug(
168+
f"Resolving file_path conflict for {entity.file_path}, "
169+
f"entity_id={existing_entity.id}, observations={len(entity.observations)}"
170+
)
166171
# Use merge to avoid session state conflicts
167172
# Set the ID to update existing entity
168173
entity.id = existing_entity.id

0 commit comments

Comments
 (0)