Harden developer memories list against malformed records#7784
Harden developer memories list against malformed records#7784tianmind-studio wants to merge 4 commits into
Conversation
Greptile SummaryThis PR hardens the
Confidence Score: 4/5Safe to merge; the changes are additive hardening on a read path and the new validators are well-tested. The coercion logic is thorough and the tests confirm the key failure scenarios. Two minor quality gaps exist: the backend/routers/developer.py — specifically the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GET /v1/dev/user/memories] --> B[memories_db.get_memories]
B --> C{For each record}
C --> D{is dict AND has id?}
D -- No --> E[Skip with warning]
D -- Yes --> F{is_locked?}
F -- Yes --> G[Truncate content to 70 chars]
G --> H[CleanerMemory.model_validate]
F -- No --> H
H --> I{ValidationError?}
I -- No --> J[Append to valid_memories]
I -- Yes --> K[Skip with warning]
J --> L[Return valid_memories]
Reviews (1): Last reviewed commit: "Make dev memories list tolerate malforme..." | Re-trigger Greptile |
d3995fd to
76fd13d
Compare
Summary
CleanerMemorytolerate legacy Developer API memory records with invalid optional fields by coercing safe defaults.created_at/updated_atvalues into UTC datetimes instead of returning raw numbers./v1/dev/user/memoriesresponses containing malformed legacy records so a single bad record does not turn the page into a 500.Regression check
With the new tests but
backend/routers/developer.pytemporarily restored toorigin/main:python -m pytest tests\unit\test_dev_api_folder_filters.py -q->2 failed, 16 passed, 2 warnings/v1/dev/user/memories?limit=3&offset=7and directCleanerMemory(...)validation errors for legacy valuesTesting
python -m pytest tests\unit\test_dev_api_folder_filters.py -q->19 passed, 2 warningspython -m black --line-length 120 --skip-string-normalization routers\developer.py tests\unit\test_dev_api_folder_filters.py --checkpython -m py_compile routers\developer.py tests\unit\test_dev_api_folder_filters.pygit diff --check