From 00589f3453e123d80abba87941cbaf66665b6e83 Mon Sep 17 00:00:00 2001 From: eehkay Date: Sat, 18 Jul 2026 09:17:57 -0700 Subject: [PATCH] fix: bigint serialization 500s in video and approval responses Two endpoints return 500 whenever they succeed, because their success payloads include VideoVersion rows whose sizeBytes column is a BigInt that JSON.stringify rejects: - PATCH /api/projects/[projectId]/videos/[videoId] included all versions; respond with scalar video fields only, which is all any caller reads - POST /api/approvals/[requestId]/decision included the full version row in the resolved request; select the scalar fields the response and notifications actually use The approval bug is reachable the first time any approver responds to a request; the decision itself commits, but the requester sees an error. Co-Authored-By: Claude Fable 5 --- app/api/approvals/[requestId]/decision/route.ts | 11 +++++++++-- .../projects/[projectId]/videos/[videoId]/route.ts | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/api/approvals/[requestId]/decision/route.ts b/app/api/approvals/[requestId]/decision/route.ts index e933e1b..f5ecf6a 100644 --- a/app/api/approvals/[requestId]/decision/route.ts +++ b/app/api/approvals/[requestId]/decision/route.ts @@ -157,10 +157,17 @@ export async function POST(request: NextRequest, { params }: RouteParams) { approver: { select: { id: true, name: true, email: true, image: true } }, }, }, + // Scalar fields only: the full version row carries BigInt sizeBytes, + // which JSON.stringify rejects when serializing the response. version: { - include: { + select: { + id: true, + versionNumber: true, + versionLabel: true, video: { - include: { + select: { + id: true, + title: true, project: { select: { id: true, name: true } }, }, }, diff --git a/app/api/projects/[projectId]/videos/[videoId]/route.ts b/app/api/projects/[projectId]/videos/[videoId]/route.ts index 1e96b6d..f01d0d0 100644 --- a/app/api/projects/[projectId]/videos/[videoId]/route.ts +++ b/app/api/projects/[projectId]/videos/[videoId]/route.ts @@ -191,12 +191,19 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) { if (typeof description === 'string') updateData.description = description.trim() || null; if (position !== undefined) updateData.position = position; + // Keep the response to scalar video fields: including versions would pull + // in BigInt columns (sizeBytes) that JSON.stringify cannot serialize, and + // no caller consumes the success payload beyond these fields. const updatedVideo = await db.video.update({ where: { id: videoId }, data: updateData, - include: { - versions: { orderBy: { versionNumber: 'desc' } }, - _count: { select: { versions: true } }, + select: { + id: true, + title: true, + description: true, + position: true, + projectId: true, + updatedAt: true, }, });