From e24bb80230406e606b61ce5237f3d369d048dc20 Mon Sep 17 00:00:00 2001 From: Gnuxie <50846879+Gnuxie@users.noreply.github.com> Date: Wed, 18 Dec 2024 00:22:35 +0000 Subject: [PATCH] Handle invalid report requests properly (#645) Sorry i forgot where I was in https://github.com/the-draupnir-project/Draupnir/commit/f07b003e41d5e3d88d5ab7b766f9cf7bdc9c3070. --- src/webapis/WebAPIs.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/webapis/WebAPIs.ts b/src/webapis/WebAPIs.ts index 149005db..cdede927 100644 --- a/src/webapis/WebAPIs.ts +++ b/src/webapis/WebAPIs.ts @@ -92,14 +92,22 @@ export class WebAPIs { const roomID = request.params.room_id; const eventID = request.params.event_id; if (!isStringRoomID(roomID)) { - throw new TypeError( + log.error( `Invalid roomID provided when processing a report, check your webproxy: ${roomID}` ); + response + .status(400) + .send({ errcode: "M_INVALID_PARAM", error: "Invalid room ID" }); + return; } if (!isStringEventID(eventID)) { - throw new TypeError( + log.error( `Invalid eventID provided when processing a report, check your webproxy: ${eventID}` ); + response + .status(400) + .send({ errcode: "M_INVALID_PARAM", error: "Invalid event ID" }); + return; } void Task( this.handleReport({