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
fix: validate olderThanDays on DELETE /api/history (#9133)
Adam Eivy860a57727278
diff --git a/server/routes/history.js b/server/routes/history.jsindex 81900a8170..aa772685e3 100644--- a/server/routes/history.js+++ b/server/routes/history.js@@ -12,6 +12,10 @@ const historyQuerySchema = z.object({success: z.preprocess(v => (v === 'true' ? true : v === 'false' ? false : undefined), z.boolean().optional()),});+const historyClearQuerySchema = z.object({+ olderThanDays: z.preprocess(v => (v !== undefined ? Number(v) : undefined), z.number().int().min(1).max(36500).optional()),+});+const router = Router();// GET /api/history - Get history entries@@ -47,8 +51,8 @@ router.delete('/:id', asyncHandler(async (req, res) => {// DELETE /api/history - Clear historyrouter.delete('/', asyncHandler(async (req, res) => {- const olderThanDays = req.query.olderThanDays ? parseInt(req.query.olderThanDays, 10) : null;- res.json(await history.clearHistory(olderThanDays));+ const { olderThanDays } = validateRequest(historyClearQuerySchema, req.query);+ res.json(await history.clearHistory(olderThanDays ?? null));}));export default router;diff --git a/server/routes/history.test.js b/server/routes/history.test.jsindex 051ca4aacc..a9185db719 100644--- a/server/routes/history.test.js+++ b/server/routes/history.test.js@@ -194,6 +194,13 @@ describe('History Routes', () => {});describe('DELETE /api/history', () => {+ it.each(['abc', '-5', '0', '1e'])('rejects olderThanDays=%s with 400 and clears nothing', async (v) => {+ const response = await request(app).delete(`/api/history?olderThanDays=${v}`);++ expect(response.status).toBe(400);+ expect(history.clearHistory).not.toHaveBeenCalled();+ });+it('should clear all history', async () => {history.clearHistory.mockResolvedValue({ success: true, deletedCount: 150 });