Return 400 for invalid publish JSON (#20)

This commit is contained in:
Autowebassat-blip 2026-06-12 06:03:19 +02:00 committed by GitHub
parent 7cda686059
commit 301b4ed535
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -217,7 +217,14 @@ async function route(request: IncomingMessage, response: ServerResponse) {
}
if (request.method === "POST" && url.pathname === "/api/plugins/sh1pt/actions/publish") {
const body = await readJson(request);
let body: unknown;
try {
body = await readJson(request);
} catch {
json(response, 400, { error: "Invalid JSON body" });
return;
}
if (!isRecord(body) || typeof body.action_id !== "string") {
json(response, 422, { error: "Expected action_id" });
return;