mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
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:
@@ -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]
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user