fix(memory): migrate legacy memories_captured v2 scopes - #1668
fix(memory): migrate legacy memories_captured v2 scopes#1668sentry[bot] wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e26e755. Configure here.
| .object({ | ||
| ...capturedMemoryFields, | ||
| scope: z.enum(MEMORY_SCOPES), | ||
| scope: z.preprocess((val) => currentScope(val as any), z.enum(MEMORY_SCOPES)), |
There was a problem hiding this comment.
Missing compatibility removal TODO
Low Severity
The new z.preprocess path tolerates legacy personal/conversation scopes at parse time, but there is no TODO(vX.Y.Z) naming that legacy state. Repo comment policy requires a dated removal marker on transitional compatibility branches.
Reviewed by Cursor Bugbot for commit e26e755. Configure here.
There was a problem hiding this comment.
Looks good to me. Coercing legacy personal/conversation scopes on the v2 memories_captured schema is the right read-path fix for residual pre-migration rows, and currentScope already matches the rename. I updated the events unit test that still expected the old Zod throw so it locks in the coercion instead.
Update the events regression test to assert coerce-on-read instead of expecting a Zod throw, and drop the preprocess any cast.
There was a problem hiding this comment.
Looks good to me. Coercing legacy personal/conversation on the v2 memories_captured parse path is the right fix for residual pre-migration rows, and the events test now locks both directions of the rename. Follow-up on the branch drops the preprocess any cast while keeping currentScope typed for render.


This PR fixes a
ZodErrorthat occurs when reading conversation history containingmemories_capturedevents with legacyscopevalues.Problem:
After DB migration #1667,
memories_capturedevents'scopefield was updated from'personal'/'conversation'to'private'/'public'. However, some existing database rows still contain the old scope values. ThecapturedMemorySchemainpackages/junior-memory/src/events.tswas only validating against the new'private'/'public'enums, causing Zod validation to fail when encountering legacy scopes.Solution:
Implemented
z.preprocesson thescopefield withincapturedMemorySchema. This preprocess step uses the existingcurrentScopehelper function to automatically coerce legacy'personal'values to'private'and'conversation'values to'public'during parsing. This ensures that allscopevalues conform to the current schema before validation, resolving theZodErrorwithout requiring a data migration.Fixes JUNIOR-8Q
This PR was automatically generated by Sentry. You can adjust this setting at any time.