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
99from diracx .db .sql import PilotAgentsDB
10+ from diracx .logic .pilots .query import MAX_PER_PAGE
1011from diracx .logic .pilots .query import search as search_bl
1112from diracx .logic .pilots .query import summary as summary_bl
1213
@@ -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 @@ -133,8 +133,8 @@ async def _search(
133133
134134 r = populated_pilot_client .post ("/api/pilots/search" , json = body , params = params )
135135
136- if r .status_code == 400 :
137- # If we have a status_code 400, that means that the query failed
136+ if r .status_code in ( 400 , 422 ) :
137+ # If we have a status_code 400/422 , that means that the query failed
138138 raise InvalidQueryError ()
139139
140140 return r .json (), r .headers
You can’t perform that action at this time.
0 commit comments