From b2506ffde1bd4682212cb49369b1fac30cebbc96 Mon Sep 17 00:00:00 2001 From: Jagadish Madavalkar Date: Thu, 1 Jan 2026 14:17:32 +0000 Subject: [PATCH] fixes api-wrapper for valid malformed response --- apps/web/modules/api/v2/auth/api-wrapper.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/web/modules/api/v2/auth/api-wrapper.ts b/apps/web/modules/api/v2/auth/api-wrapper.ts index 47326050f8..e03d2abc75 100644 --- a/apps/web/modules/api/v2/auth/api-wrapper.ts +++ b/apps/web/modules/api/v2/auth/api-wrapper.ts @@ -67,7 +67,21 @@ export const apiWrapper = async ({ let parsedInput: ParsedSchemas = {} as ParsedSchemas; if (schemas?.body) { - const bodyData = await request.json(); + let bodyData; + try { + bodyData = await request.json(); + } catch (error) { + return handleApiError(request, { + type: "bad_request", + details: [ + { + field: "error", + issue: "Malformed JSON input, please check your request body", + }, + ], + }); + } + const bodyResult = schemas.body.safeParse(bodyData); if (!bodyResult.success) {