Skip to content

GET /rest/v1/text_search without text param causes unhandled TypeError #862

@shiwani42

Description

@shiwani42

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions