fix(memory): return 200 with null data when memory key not found on GET (#4421)

* fix(memory): return 200 with null data when memory key not found on GET

* test(memory): add null-data path test for memory_get transformResponse
This commit is contained in:
Waleed
2026-05-03 02:48:19 -07:00
committed by GitHub
parent 68f66ba3f3
commit f76a10ca55
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ export const GET = withRouteHandler(async (request: NextRequest, context: Memory
.limit(1)
if (memories.length === 0) {
return memoryEnvelopeError('Memory not found', 404)
return NextResponse.json({ success: true, data: null }, { status: 200 })
}
const mem = memories[0]
+14
View File
@@ -36,6 +36,20 @@ describe('memoryGetTool', () => {
expect(url).toBe('/api/memory/team%2Fuser%20123?workspaceId=workspace-1')
})
it('returns empty memories when key is not found (null data)', async () => {
const result = await transformResponse(
new Response(JSON.stringify({ success: true, data: null }))
)
expect(result).toEqual({
success: true,
output: {
memories: [],
message: 'No memories found',
},
})
})
it('wraps the exact memory response as a single result', async () => {
const result = await transformResponse(
new Response(