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: parse archived-record query booleans explicitly

[._.]/ Adam Eivy6c4bfce60806
diff --git a/server/lib/brainValidation.js b/server/lib/brainValidation.js
index 2980c00968..91818f612e 100644
--- a/server/lib/brainValidation.js
+++ b/server/lib/brainValidation.js
@@ -337,7 +337,12 @@ export const entityQuerySchema = z.object({
cursor: z.preprocess((val) => (val === '' || val === null || val === 'null' ? undefined : val), z.string().max(512).optional()),
limit: z.coerce.number().int().min(1).max(100).optional().default(25),
offset: z.coerce.number().int().min(0).optional().default(0),
- includeArchived: z.coerce.boolean().optional().default(false)
+ includeArchived: z.preprocess(
+ (value) => (typeof value === 'string'
+ ? value === 'true' ? true : value === 'false' ? false : value
+ : value),
+ z.boolean()
+ ).optional().default(false)
});
// --- Extracted field schemas for AI classification ---
diff --git a/server/lib/brainValidation.test.js b/server/lib/brainValidation.test.js
index 014b209de2..d019800668 100644
--- a/server/lib/brainValidation.test.js
+++ b/server/lib/brainValidation.test.js
@@ -27,6 +27,7 @@ import {
ideaInputSchema,
adminInputSchema,
inboxQuerySchema,
+ entityQuerySchema,
linkRecordSchema,
linkInputSchema,
linkUpdateInputSchema,
@@ -502,6 +503,18 @@ describe('brainValidation.js', () => {
});
});
+ describe('entityQuerySchema', () => {
+ it('parses query-string booleans without treating "false" as true', () => {
+ expect(entityQuerySchema.parse({ includeArchived: 'true' }).includeArchived).toBe(true);
+ expect(entityQuerySchema.parse({ includeArchived: 'false' }).includeArchived).toBe(false);
+ expect(entityQuerySchema.parse({}).includeArchived).toBe(false);
+ });
+
+ it('rejects an invalid query-string boolean', () => {
+ expect(entityQuerySchema.safeParse({ includeArchived: 'yes' }).success).toBe(false);
+ });
+ });
+
describe('linkRecordSchema', () => {
it('should validate a complete link record', () => {
const record = {