diff --git a/application/tests/web_main_test.py b/application/tests/web_main_test.py index 9e219b4ce..322d47515 100644 --- a/application/tests/web_main_test.py +++ b/application/tests/web_main_test.py @@ -475,6 +475,14 @@ def test_test_search(self) -> None: self.assertEqual(200, resp.status_code) self.assertDictEqual(resp.json[0], expected[0]) + def test_text_search_missing_param(self) -> None: + with self.app.test_client() as client: + response = client.get("/rest/v1/text_search") + self.assertEqual(400, response.status_code) + + response = client.get("/rest/v1/text_search?text=") + self.assertEqual(400, response.status_code) + def test_find_root_cres(self) -> None: self.maxDiff = None collection = db.Node_collection().with_graph() diff --git a/application/web/web_main.py b/application/web/web_main.py index 29567470a..3e76fab9c 100644 --- a/application/web/web_main.py +++ b/application/web/web_main.py @@ -472,6 +472,8 @@ def text_search() -> Any: """ database = db.Node_collection() text = request.args.get("text") + if not text: + abort(400, "text parameter is required") if posthog: posthog.capture(f"text_search", f"text:{text}")