Skip to content

Commit 6b877bc

Browse files
committed
fix(webapp): wrap admin.notifications archive/delete/publish handlers in try/catch
The three Prisma-backed dashboard action helpers (archivePlatformNotification, deletePlatformNotification, publishNowPlatformNotification) throw on underlying DB errors. Without try/catch in the route handler, the throw escapes to Remix's default action error response, which serialises message + stack into the JSON body — exposing server-side details and absolute build paths to the dashboard caller. Wrap each handler in try/catch with logger.error + a generic 500 typedjson body, matching the pattern already used by handleCreateAction and handleEditAction in the same file.
1 parent 15b1eb8 commit 6b877bc

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

apps/webapp/app/routes/admin.notifications.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,13 @@ async function handleArchiveAction(formData: FormData) {
251251
return typedjson({ error: "Missing notificationId" }, { status: 400 });
252252
}
253253

254-
await archivePlatformNotification(notificationId);
255-
return typedjson({ success: true });
254+
try {
255+
await archivePlatformNotification(notificationId);
256+
return typedjson({ success: true });
257+
} catch (error) {
258+
logger.error("Failed to archive platform notification", { error });
259+
return typedjson({ error: "Failed to archive notification" }, { status: 500 });
260+
}
256261
}
257262

258263
async function handleDeleteAction(formData: FormData) {
@@ -261,8 +266,13 @@ async function handleDeleteAction(formData: FormData) {
261266
return typedjson({ error: "Missing notificationId" }, { status: 400 });
262267
}
263268

264-
await deletePlatformNotification(notificationId);
265-
return typedjson({ success: true });
269+
try {
270+
await deletePlatformNotification(notificationId);
271+
return typedjson({ success: true });
272+
} catch (error) {
273+
logger.error("Failed to delete platform notification", { error });
274+
return typedjson({ error: "Failed to delete notification" }, { status: 500 });
275+
}
266276
}
267277

268278
async function handlePublishNowAction(formData: FormData) {
@@ -271,8 +281,13 @@ async function handlePublishNowAction(formData: FormData) {
271281
return typedjson({ error: "Missing notificationId" }, { status: 400 });
272282
}
273283

274-
await publishNowPlatformNotification(notificationId);
275-
return typedjson({ success: true });
284+
try {
285+
await publishNowPlatformNotification(notificationId);
286+
return typedjson({ success: true });
287+
} catch (error) {
288+
logger.error("Failed to publish platform notification", { error });
289+
return typedjson({ error: "Failed to publish notification" }, { status: 500 });
290+
}
276291
}
277292

278293
async function handleEditAction(formData: FormData) {

0 commit comments

Comments
 (0)