potpie
potpie copied to clipboard
Prevent API Calls with Empty Query Parameter in Search API
Description
Currently, the search API (app/modules/search/search_router.py) allows empty search queries, which leads to unnecessary database operations and API calls. When a user submits a search with an empty query string, the system still processes the request and returns results.
Current Behavior
- Empty search query strings are accepted
- The system performs database operations even with empty queries
- Resources are wasted on meaningless search operations
Expected Behavior
- Validate the
queryparameter inSearchRequest - Return a 400 Bad Request response when the query is empty or contains only whitespace
- Include a clear error message explaining that search queries cannot be empty
Code Location
app/modules/search/search_router.pyapp/modules/search/search_schema.py