From 1bd30807fb4f9ad69d773b07a00178eed6efb565 Mon Sep 17 00:00:00 2001 From: "groombook-ci[bot]" Date: Sun, 29 Mar 2026 14:05:52 +0000 Subject: [PATCH] fix(api): add error handling to /api/staff/me endpoint Wrap c.json() in try/catch to surface serialization errors rather than crashing silently. Also guard against null staff context. Co-Authored-By: Paperclip --- apps/api/src/routes/staff.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/staff.ts b/apps/api/src/routes/staff.ts index 3aa2f1a..845e15d 100644 --- a/apps/api/src/routes/staff.ts +++ b/apps/api/src/routes/staff.ts @@ -25,7 +25,15 @@ const updateStaffSchema = z.object({ staffRouter.get("/me", async (c) => { const staffRow = c.get("staff"); - return c.json(staffRow); + if (!staffRow) { + return c.json({ error: "Staff record not found in context" }, 500); + } + try { + return c.json(staffRow); + } catch (err) { + console.error("[/api/staff/me] serialization error:", err, "staffRow:", staffRow); + return c.json({ error: "Serialization error", detail: String(err) }, 500); + } }); staffRouter.get("/", async (c) => {