From 03299a9c7895a720d3ead09c55f14ad0fa995bee Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 22 Aug 2026 04:32:57 +0000 Subject: [PATCH] fix(POR-22656): handle platform Price.prices.amount unmarshaling errors in notification-center Co-authored-by: Neil Raina --- src/app/notification-center/page.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/notification-center/page.tsx b/src/app/notification-center/page.tsx index e39b77851..734ef4cb9 100644 --- a/src/app/notification-center/page.tsx +++ b/src/app/notification-center/page.tsx @@ -1,5 +1,5 @@ import { SilentError } from '@/components/templates/SilentError' -import { NotificationInProductCtaParamsSchema } from '@/types/common' +import { NotificationInProductCtaParamsSchema, Uuid } from '@/types/common' import { UserType } from '@/types/interfaces' import { CopilotAPI } from '@/utils/CopilotAPI' import { redirectIfTaskCta } from '@/utils/redirect' @@ -9,9 +9,9 @@ async function getNotificationDetail(token: string) { const copilot = new CopilotAPI(token) const tokenPayload = await copilot.getTokenPayload() - if (!tokenPayload) throw new Error('Failed to get token payload') + if (!tokenPayload?.notificationId || !Uuid.safeParse(tokenPayload.notificationId).success) return null - return await copilot.getIUNotification(z.string().parse(tokenPayload.notificationId), tokenPayload.workspaceId) // notification "id" is expected in tokenPayload + return await copilot.getIUNotification(tokenPayload.notificationId, tokenPayload.workspaceId) } export default async function NotificationCenter(props: { searchParams: Promise<{ token: string }> }) { @@ -21,13 +21,24 @@ export default async function NotificationCenter(props: { searchParams: Promise< return } - const notificationDetail = await getNotificationDetail(token) + let notificationDetail + try { + notificationDetail = await getNotificationDetail(token) + } catch (error) { + console.warn('notification-center: failed to load notification', error) + return + } + if (!notificationDetail) return - const params = NotificationInProductCtaParamsSchema.parse(notificationDetail.deliveryTargets?.inProduct?.ctaParams) + const params = NotificationInProductCtaParamsSchema.safeParse( + notificationDetail.deliveryTargets?.inProduct?.ctaParams, + ) + if (!params.success) { + return + } - redirectIfTaskCta({ ...params, ...searchParams }, UserType.INTERNAL_USER, true) + redirectIfTaskCta({ ...params.data, ...searchParams }, UserType.INTERNAL_USER, true) - // Silent Error is shown if redirect fails. Only possible reason for redirect to not work can be of the taskId not found return }