summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-02-11 19:16:41 -0800
committerBryan Newbold <bnewbold@archive.org>2021-02-11 19:16:41 -0800
commitc8ca2bcf4000af98f5b4ba8512d14049fce7fc7d (patch)
tree774690758b432a482a700dc8a27f3cce4943c04b /fatcat_scholar
parent9b5e1827331f1c609b3af9fef6067dc91bad53f2 (diff)
downloadfatcat-scholar-c8ca2bcf4000af98f5b4ba8512d14049fce7fc7d.tar.gz
fatcat-scholar-c8ca2bcf4000af98f5b4ba8512d14049fce7fc7d.zip
api: handle null 'q' parameter on search endpoint
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/web.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py
index 124e269..31ee617 100644
--- a/fatcat_scholar/web.py
+++ b/fatcat_scholar/web.py
@@ -97,6 +97,8 @@ class HitsModel(BaseModel):
@api.get("/search", operation_id="get_search", response_model=HitsModel)
async def search(query: FulltextQuery = Depends(FulltextQuery)) -> FulltextHits:
hits: Optional[FulltextHits] = None
+ if query.q is None:
+ raise HTTPException(status_code=400, detail=f"Expected a 'q' query parameter")
try:
hits = process_query(query)
except ValueError as e: