Fix list_memories endpoint Pydantic validation error#3608
Merged
prateekchhikara merged 1 commit intomem0ai:mainfrom Oct 18, 2025
Merged
Conversation
- Add transformer to convert ORM objects to MemoryResponse schema - Add eager loading with joinedload for app and categories - Follow pattern from filter_memories endpoint (lines 412-503)
Contributor
|
Hey @frederikb96 thank you for raising this PR. |
VikramIyer125
approved these changes
Oct 18, 2025
Contributor
|
Approved @frederikb96 |
garciaba79
pushed a commit
to garciaba79/mem0
that referenced
this pull request
Feb 12, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Problem
The
list_memoriesendpoint (GET/api/v1/memories/) was returning 500 Internal Server Error when searching for memories.What was broken:
MemoryResponseschemaapp,categories) that need to be transformedValidationError: Field required [type=missing, input_value=<Memory object>]How It's Done Elsewhere
Looking at the same file, the
filter_memoriesendpoint (lines 412-503) already handles this correctly:joinedload(Memory.app, Memory.categories)for eager loadingtransformerparameter insqlalchemy_paginateto convert ORM → Pydantic schemaMemoryResponseobjects manually with proper field extractionThe Fix
Applied the same pattern to
list_memories:joinedload(Memory.app, Memory.categories).distinct(Memory.id)to prevent duplicates from joinsMemoryResponseschemaType of change
How Has This Been Tested?
infer=Trueandinfer=Falsememory additionsChecklist:
filter_memoriesendpoint