Skip to content

Commit 301b4ed

Browse files
Return 400 for invalid publish JSON (#20)
1 parent 7cda686 commit 301b4ed

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/commandboard-api/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ async function route(request: IncomingMessage, response: ServerResponse) {
217217
}
218218

219219
if (request.method === "POST" && url.pathname === "/api/plugins/sh1pt/actions/publish") {
220-
const body = await readJson(request);
220+
let body: unknown;
221+
try {
222+
body = await readJson(request);
223+
} catch {
224+
json(response, 400, { error: "Invalid JSON body" });
225+
return;
226+
}
227+
221228
if (!isRecord(body) || typeof body.action_id !== "string") {
222229
json(response, 422, { error: "Expected action_id" });
223230
return;

0 commit comments

Comments
 (0)