From bba43d4260f10029a863a4a2fa82f224d48027d5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 3 Aug 2025 01:41:45 +0000 Subject: [PATCH] fix: resolve TypeScript type errors in reports API endpoints - Add proper validation for reportId parameter to ensure it's not undefined - Fix type mismatch in updatedReport by conditionally spreading only defined fields - Maintain API contract where updates are partial but responses are complete Co-Authored-By: nate@buster.so --- apps/server/src/api/v2/reports/[id].ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/server/src/api/v2/reports/[id].ts b/apps/server/src/api/v2/reports/[id].ts index 62a06c78b..fce49c5f4 100644 --- a/apps/server/src/api/v2/reports/[id].ts +++ b/apps/server/src/api/v2/reports/[id].ts @@ -39,9 +39,12 @@ async function updateReportHandler( throw new HTTPException(404, { message: 'Report not found' }); } - const updatedReport = { + const updatedReport: UpdateReportResponse = { ...existingReport, - ...request, + ...(request.name !== undefined && { name: request.name }), + ...(request.description !== undefined && { description: request.description }), + ...(request.publicly_accessible !== undefined && { publicly_accessible: request.publicly_accessible }), + ...(request.content !== undefined && { content: request.content }), updated_at: new Date().toISOString() }; @@ -51,6 +54,9 @@ async function updateReportHandler( const app = new Hono() .put('/', zValidator('json', UpdateReportRequestSchema), async (c) => { const reportId = c.req.param('id'); + if (!reportId) { + throw new HTTPException(400, { message: 'Report ID is required' }); + } const request = c.req.valid('json'); const user = c.get('busterUser');