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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (self): tolerate null testIds run-all sentinel
[._.]/ Adam Eivy91fe0fc05e60
diff --git a/server/lib/digitalTwinValidation.js b/server/lib/digitalTwinValidation.jsindex ef80282098..259de3a71a 100644--- a/server/lib/digitalTwinValidation.js+++ b/server/lib/digitalTwinValidation.js@@ -203,11 +203,19 @@ export const updateDocumentInputSchema = z.object({weight: z.number().int().min(1).max(10).optional()});+// testIds is "all tests" when absent. The client API wrappers default the+// argument to `null` (not `undefined`), so tolerate the null sentinel —+// `.optional()` alone rejects `null` and would 400 a "run all" request.+const optionalTestIds = z.preprocess(+ v => v == null ? undefined : v,+ z.array(z.number().int().min(1)).optional()+);+// Run tests inputexport const runTestsInputSchema = z.object({providerId: z.string().min(1),model: z.string().min(1),- testIds: z.array(z.number().int().min(1)).optional()+ testIds: optionalTestIds});// Run multi-model tests input@@ -216,7 +224,7 @@ export const runMultiTestsInputSchema = z.object({providerId: z.string().min(1),model: z.string().min(1)})).min(1).max(10),- testIds: z.array(z.number().int().min(1)).optional()+ testIds: optionalTestIds});// Enrichment question inputdiff --git a/server/lib/digitalTwinValidation.test.js b/server/lib/digitalTwinValidation.test.jsnew file mode 100644index 0000000000..d0004ce387--- /dev/null+++ b/server/lib/digitalTwinValidation.test.js@@ -0,0 +1,33 @@+import { describe, it, expect } from 'vitest';+import { runTestsInputSchema, runMultiTestsInputSchema } from './digitalTwinValidation.js';++// Regression guard: the client API wrappers default `testIds` to `null` for a+// "run all tests" request. A bare `.optional()` rejects null and would 400+// every UI-triggered run — the values-alignment panel always sends null.+describe('runTestsInputSchema testIds null-tolerance', () => {+ it('accepts testIds: null (run-all sentinel) and normalizes it away', () => {+ const parsed = runTestsInputSchema.parse({ providerId: 'p', model: 'm', testIds: null });+ expect(parsed.testIds).toBeUndefined();+ });++ it('accepts an explicit array of test ids', () => {+ const parsed = runTestsInputSchema.parse({ providerId: 'p', model: 'm', testIds: [1, 2] });+ expect(parsed.testIds).toEqual([1, 2]);+ });++ it('accepts an omitted testIds', () => {+ expect(runTestsInputSchema.parse({ providerId: 'p', model: 'm' }).testIds).toBeUndefined();+ });++ it('still rejects malformed test ids', () => {+ expect(runTestsInputSchema.safeParse({ providerId: 'p', model: 'm', testIds: ['x'] }).success).toBe(false);+ });++ it('tolerates null testIds on the multi-model schema too', () => {+ const parsed = runMultiTestsInputSchema.parse({+ providers: [{ providerId: 'p', model: 'm' }],+ testIds: null+ });+ expect(parsed.testIds).toBeUndefined();+ });+});