fix(server): return 404/400 instead of 502 for not-found and invalid input (#5634)

This commit is contained in:
Yash Singh
2026-06-22 11:47:48 +05:30
committed by GitHub
parent 8a786bf72d
commit 1676b3168d
4 changed files with 115 additions and 2 deletions
+4 -2
View File
@@ -1842,8 +1842,9 @@ class Memory(MemoryBase):
try:
existing_memory = self.vector_store.get(vector_id=memory_id)
except Exception:
# Backing-store failure, not a bad memory_id: re-raise the original so the REST layer maps it to 5xx, not 4xx.
logger.error(f"Error getting memory with ID {memory_id} during update.")
raise ValueError(f"Error getting memory with ID {memory_id}. Please provide a valid 'memory_id'")
raise
if existing_memory is None:
raise ValueError(f"Memory with id {memory_id} not found. Please provide a valid 'memory_id'")
@@ -3406,8 +3407,9 @@ class AsyncMemory(MemoryBase):
try:
existing_memory = await asyncio.to_thread(self.vector_store.get, vector_id=memory_id)
except Exception:
# Backing-store failure, not a bad memory_id: re-raise the original so the REST layer maps it to 5xx, not 4xx.
logger.error(f"Error getting memory with ID {memory_id} during update.")
raise ValueError(f"Error getting memory with ID {memory_id}. Please provide a valid 'memory_id'")
raise
if existing_memory is None:
raise ValueError(f"Memory with id {memory_id} not found. Please provide a valid 'memory_id'")