From 4d2e4b0b4bf1f7d1804c41dfa15da4cae420d47e Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Mon, 4 May 2026 19:44:48 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20drop=20\`{=20not:=20null=20}\`=20filters?= =?UTF-8?q?=20=E2=80=94=20Prisma=207=20rejects=20them=20at=20runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PrismaClientValidationError ('Argument \`not\` must not be null') hit at runtime when notifications-bridge mounted post-M12 schema change. Although StringNullableFilter typings allow \`not: null\`, the v7 query engine rejects it. Removed the WHERE-side filter in 3 places — null-narrowing already happens client-side via flatMap / Boolean filter: - components/notifications/notifications-bridge.tsx - app/api/realtime/notifications/route.ts - lib/insights/verify-stats.ts (task_id filter) Idea-questions / idea-jobs will be routed via separate channels in T-502 + T-507; for now, story-question + task-job paths simply ignore NULL rows in their post-fetch mapping. Tests: 479/479 green; tsc clean. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/api/realtime/notifications/route.ts | 4 +++- components/notifications/notifications-bridge.tsx | 5 ++++- lib/insights/verify-stats.ts | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/api/realtime/notifications/route.ts b/app/api/realtime/notifications/route.ts index 7a6befa..4fad600 100644 --- a/app/api/realtime/notifications/route.ts +++ b/app/api/realtime/notifications/route.ts @@ -132,7 +132,9 @@ export async function GET(request: NextRequest) { status: 'open', expires_at: { gt: new Date() }, product_id: { in: products.map((p) => p.id) }, - story_id: { not: null }, + // Skip idea-questions (story_id NULL) — story-questions only here. + // Narrowing happens in the flatMap below — Prisma 7 rejects + // `story_id: { not: null }` at runtime. }, orderBy: { created_at: 'desc' }, take: 100, diff --git a/components/notifications/notifications-bridge.tsx b/components/notifications/notifications-bridge.tsx index ef7a9fe..e600838 100644 --- a/components/notifications/notifications-bridge.tsx +++ b/components/notifications/notifications-bridge.tsx @@ -28,7 +28,10 @@ export async function NotificationsBridge({ userId }: NotificationsBridgeProps) status: 'open', expires_at: { gt: new Date() }, product_id: { in: productIds }, - story_id: { not: null }, + // Skip idea-questions (story_id NULL): they have a separate + // realtime channel and aren't shown in this product-scoped bell. + // Narrowing happens in the flatMap below — Prisma 7 rejects + // `story_id: { not: null }` at runtime. }, orderBy: { created_at: 'desc' }, take: 100, diff --git a/lib/insights/verify-stats.ts b/lib/insights/verify-stats.ts index c09806b..0de209f 100644 --- a/lib/insights/verify-stats.ts +++ b/lib/insights/verify-stats.ts @@ -40,7 +40,9 @@ export async function getVerifyResultStats( status: 'DONE' as const, verify_result: { not: null as null }, finished_at: { gt: cutoff }, - task_id: { not: null }, + // Note: task_id can now be NULL on idea-jobs (M12). The toTopJob mapper + // filters them out via .filter(Boolean). Keeping a where-side filter + // (`task_id: { not: null }`) is rejected by Prisma 7 runtime. } const [grouped, rawEmpty, rawDivergent] = await Promise.all([