Skip to content

Commit 76252d7

Browse files
committed
fix(webapp): wrap playground 'save' JSON.parse to return 400 on malformed input
Mirrors the 'start' case (lines 104-108) — uncaught JSON.parse on a malformed messages form field surfaced as an unhandled 500 instead of a clean 400. Addresses Devin review on PR #3173.
1 parent 98f89a2 commit 76252d7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.playground.action.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
239239
return json({ error: "chatId is required" }, { status: 400 });
240240
}
241241

242-
const messagesData = messagesStr ? JSON.parse(messagesStr) : undefined;
242+
let messagesData: unknown;
243+
try {
244+
messagesData = messagesStr ? JSON.parse(messagesStr) : undefined;
245+
} catch {
246+
return json({ error: "Invalid messages JSON" }, { status: 400 });
247+
}
243248

244249
// Extract title from the first user message if the conversation still has the default title.
245250
// This handles the case where a preloaded conversation gets its first real message

0 commit comments

Comments
 (0)