Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: refuse reserved names as memory item chunk ids

Adam Eivycf1c43638d00
diff --git a/server/lib/postValidation.js b/server/lib/postValidation.js
index 55868c14f7..39a7ab7868 100644
--- a/server/lib/postValidation.js
+++ b/server/lib/postValidation.js
@@ -508,7 +508,8 @@ const memoryLineSchema = z.object({
});
const memoryChunkSchema = z.object({
- id: z.string(),
+ // Practice submits this id as a mastery key, so it takes the same check.
+ id: masteryKeySchema,
lineRange: z.array(z.number().int().min(0)).length(2),
label: z.string(),
});
diff --git a/server/lib/postValidation.test.js b/server/lib/postValidation.test.js
index 3d6b55a330..5bad832726 100644
--- a/server/lib/postValidation.test.js
+++ b/server/lib/postValidation.test.js
@@ -418,6 +418,10 @@ describe('questionResultSchema chunkId/element (issue #2016)', () => {
expect(memoryPracticeSchema.safeParse({ mode: 'sequence', chunkId: key, results: [{ correct: true }] }).success).toBe(false);
expect(memoryPracticeSchema.safeParse({ mode: 'element-flash', results: [{ correct: true, element: key }] }).success).toBe(false);
expect(memoryPracticeSchema.safeParse({ mode: 'sequence', chunkId: 'verse-1', results: [{ correct: true, chunkId: 'verse-1' }] }).success).toBe(true);
+ // An item saved with such a chunk id could never be practiced.
+ const item = (id) => ({ title: 'Song', type: 'song', lines: ['a'], chunks: [{ id, lineRange: [0, 0], label: 'Verse' }] });
+ expect(memoryItemCreateSchema.safeParse(item(key)).success).toBe(false);
+ expect(memoryItemCreateSchema.safeParse(item('verse-1')).success).toBe(true);
});
it('accepts a null chunkId (question with no matching chunk)', () => {