From 9edcbe8beac016b4e22538eb18a7b2708520457e Mon Sep 17 00:00:00 2001 From: Mufeed Ali Date: Sun, 20 Feb 2022 22:52:12 +0530 Subject: [PATCH] suggestions: Abort when missing parameters --- app/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/app.py b/app/app.py index 0bbe02a..03f63f4 100644 --- a/app/app.py +++ b/app/app.py @@ -903,6 +903,15 @@ def create_app(args): source_lang = request.values.get("source") target_lang = request.values.get("target") + if not q: + abort(400, description="Invalid request: missing q parameter") + if not s: + abort(400, description="Invalid request: missing s parameter") + if not source_lang: + abort(400, description="Invalid request: missing source parameter") + if not target_lang: + abort(400, description="Invalid request: missing target parameter") + SuggestionsDatabase().add(q, s, source_lang, target_lang) return jsonify({"success": True})