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
review: reject unrecognized preview token instead of coercing to real import (#2160)
Adam Eivy41e6512ecccf
diff --git a/server/routes/timeline.js b/server/routes/timeline.jsindex aeabbcb2ea..8e93b5b7fa 100644--- a/server/routes/timeline.js+++ b/server/routes/timeline.js@@ -23,12 +23,17 @@ const uploadSpotify = uploadSingle('file', {});// `preview` (a multipart text field, so it arrives as a string) toggles a-// parse-only dry run — count what would be imported without writing.+// parse-only dry run — count what would be imported without writing. Only map+// the recognized true/false tokens; any other string is left as-is so Zod+// rejects it with a 400 rather than silently coercing an unknown value to a+// (write-path) real import.const importBodySchema = z.object({- preview: z.preprocess(- (v) => (typeof v === 'string' ? v === 'true' || v === '1' : v),- z.boolean().optional().default(false),- ),+ preview: z.preprocess((v) => {+ if (typeof v !== 'string') return v;+ if (v === 'true' || v === '1') return true;+ if (v === 'false' || v === '0' || v === '') return false;+ return v; // unrecognized → Zod boolean check fails → 400+ }, z.boolean().optional().default(false)),});const dayQuerySchema = z.object({diff --git a/server/routes/timeline.test.js b/server/routes/timeline.test.jsindex dce6ced018..b8eb6683da 100644--- a/server/routes/timeline.test.js+++ b/server/routes/timeline.test.js@@ -99,6 +99,18 @@ describe('timeline import routes', () => {expect(importSpotifyHistory).toHaveBeenCalledWith(expect.anything(), { dryRun: false });});+ it('400s on an unrecognized preview token instead of silently importing', async () => {+ const { boundary, body } = multipart(+ { preview: 'maybe' },+ { filename: 'history.json', contentType: 'application/json', content: '[]' },+ );+ const r = await request(app).post('/api/timeline/import/spotify')+ .set('content-type', `multipart/form-data; boundary=${boundary}`)+ .send(body);+ expect(r.status).toBe(400);+ expect(importSpotifyHistory).not.toHaveBeenCalled();+ });+it('rejects a disallowed file type with 400', async () => {const { boundary, body } = multipart({},