Issue
What is the issue?
request.args.get("text") returns None when the text query parameter is not provided. This None is passed directly into db.text_search(), which calls re.search(pattern, text, re.IGNORECASE) on line 1821 of application/database/db.py.
re.search does not accept None as the string argument and raises:
TypeError: expected string or bytes-like object
There is no guard between the endpoint and the regex call.
Expected Behaviour
GET /rest/v1/text_search without a text parameter returns a 400 with a descriptive error message.
Actual Behaviour
The endpoint returns a 500 with an unhandled TypeError.
Steps to reproduce
curl "http://localhost:5000/rest/v1/text_search"
Issue
What is the issue?
request.args.get("text")returnsNonewhen thetextquery parameter is not provided. ThisNoneis passed directly intodb.text_search(), which callsre.search(pattern, text, re.IGNORECASE)on line 1821 ofapplication/database/db.py.re.searchdoes not acceptNoneas the string argument and raises:There is no guard between the endpoint and the regex call.
Expected Behaviour
GET /rest/v1/text_searchwithout atextparameter returns a 400 with a descriptive error message.Actual Behaviour
The endpoint returns a 500 with an unhandled
TypeError.Steps to reproduce