Skip to content

Commit f76a10c

Browse files
authored
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
1 parent 68f66ba commit f76a10c

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

apps/sim/app/api/memory/[id]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const GET = withRouteHandler(async (request: NextRequest, context: Memory
8686
.limit(1)
8787

8888
if (memories.length === 0) {
89-
return memoryEnvelopeError('Memory not found', 404)
89+
return NextResponse.json({ success: true, data: null }, { status: 200 })
9090
}
9191

9292
const mem = memories[0]

apps/sim/tools/memory/get.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ describe('memoryGetTool', () => {
3636
expect(url).toBe('/api/memory/team%2Fuser%20123?workspaceId=workspace-1')
3737
})
3838

39+
it('returns empty memories when key is not found (null data)', async () => {
40+
const result = await transformResponse(
41+
new Response(JSON.stringify({ success: true, data: null }))
42+
)
43+
44+
expect(result).toEqual({
45+
success: true,
46+
output: {
47+
memories: [],
48+
message: 'No memories found',
49+
},
50+
})
51+
})
52+
3953
it('wraps the exact memory response as a single result', async () => {
4054
const result = await transformResponse(
4155
new Response(

0 commit comments

Comments
 (0)