fix: handle malformed JSON in location handler

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-02-22 21:03:58 +00:00
parent c0b3db0e11
commit 963bf073d1

View File

@@ -29,7 +29,13 @@ export function registerLocationHttpHandlers(
}
async function handleUpdateLocation(c: Context<Env>) {
const body = await c.req.json()
let body: unknown
try {
body = await c.req.json()
} catch {
return c.json({ error: "Invalid JSON" }, 400)
}
const result = locationInput(body)
if (result instanceof type.errors) {