From bfa037885f2a69323e9be922e420b0c115699dfa Mon Sep 17 00:00:00 2001 From: dmitriylaukhin Date: Sat, 25 Apr 2026 17:58:13 +0500 Subject: [PATCH] Fix saveLesson: sanitize content JSON to prevent RSC proxy error React treats TipTap's editor.getJSON() output as a non-plain object when passed through Server Action serialization, causing isDecimal() inside Prisma's query builder to receive a temporary client reference proxy and throw ERROR 1213974697. JSON.parse(JSON.stringify()) strips the prototype chain and any non-enumerable properties, ensuring Prisma receives a clean plain object. Co-Authored-By: Claude Sonnet 4.6 --- src/lib/actions/lesson-actions.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/lib/actions/lesson-actions.ts b/src/lib/actions/lesson-actions.ts index 1496123..47a2f5b 100644 --- a/src/lib/actions/lesson-actions.ts +++ b/src/lib/actions/lesson-actions.ts @@ -22,20 +22,15 @@ export async function saveLesson( } ) { await requireAdmin(); - try { - await prisma.lesson.update({ - where: { id: lessonId }, - data: { - title: data.title, - kinescopeId: data.kinescopeId || null, - content: JSON.parse(JSON.stringify(data.content)), - published: data.published, - }, - }); - } catch (err) { - console.error("[saveLesson] full error:", err); - throw err; - } + await prisma.lesson.update({ + where: { id: lessonId }, + data: { + title: data.title, + kinescopeId: data.kinescopeId || null, + content: JSON.parse(JSON.stringify(data.content)), + published: data.published, + }, + }); revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`); revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`); }