File tree Expand file tree Collapse file tree
src/diracx/routers/pilots Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from http import HTTPStatus
44from typing import Annotated , Any
55
6- from fastapi import Body , Depends , Response
6+ from fastapi import Body , Depends , Query , Response
77
88from diracx .core .models .search import SearchParams , SummaryParams
9+ from diracx .logic .pilots .query import MAX_PER_PAGE
910from diracx .logic .pilots .query import search as search_bl
1011from diracx .logic .pilots .query import summary as summary_bl
1112
@@ -111,8 +112,8 @@ async def search(
111112 check_permissions : CheckPilotManagementPolicyCallable ,
112113 response : Response ,
113114 user_info : Annotated [AuthorizedUserInfo , Depends (verify_dirac_access_token )],
114- page : int = 1 ,
115- per_page : int = 100 ,
115+ page : Annotated [ int , Query ( ge = 1 )] = 1 ,
116+ per_page : Annotated [ int , Query ( ge = 1 , le = MAX_PER_PAGE )] = 100 ,
116117 body : Annotated [
117118 SearchParams | None , Body (openapi_examples = EXAMPLE_SEARCHES ) # type: ignore
118119 ] = None ,
Original file line number Diff line number Diff line change @@ -140,8 +140,8 @@ async def _search(
140140
141141 r = populated_pilot_client .post ("/api/pilots/search" , json = body , params = params )
142142
143- if r .status_code == 400 :
144- # If we have a status_code 400, that means that the query failed
143+ if r .status_code in ( 400 , 422 ) :
144+ # If we have a status_code 400/422 , that means that the query failed
145145 raise InvalidQueryError ()
146146
147147 return r .json (), r .headers
You can’t perform that action at this time.
0 commit comments