Skip to content

Commit bd1b306

Browse files
committed
Refactor FactsClient methods to remove optional query parameters
- Updated `build_forward_request` and `send_forward_request` methods in `FactsClient` to eliminate the optional `query_params` argument, simplifying the request handling process. - Adjusted related calls in `facts_router` to align with the new method signatures, ensuring consistent behavior across the application.
1 parent e2fce25 commit bd1b306

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

horizon/facts/client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Annotated, Any
1+
from typing import Annotated
22
from urllib.parse import urljoin
33

44
from fastapi import Depends, HTTPException
@@ -31,7 +31,9 @@ def client(self) -> AsyncClient:
3131
return self._client
3232

3333
async def build_forward_request(
34-
self, request: FastApiRequest, path: str, *, query_params: dict[str, Any] | None = None
34+
self,
35+
request: FastApiRequest,
36+
path: str,
3537
) -> HttpxRequest:
3638
"""
3739
Build an HTTPX request from a FastAPI request to forward to the facts service.
@@ -55,7 +57,7 @@ async def build_forward_request(
5557
return self.client.build_request(
5658
method=request.method,
5759
url=full_path,
58-
params={**request.query_params, **(query_params or {})},
60+
params=request.query_params,
5961
headers=forward_headers,
6062
content=request.stream(),
6163
)
@@ -65,15 +67,17 @@ async def send(self, request: HttpxRequest, *, stream: bool = False) -> HttpxRes
6567
return await self.client.send(request, stream=stream)
6668

6769
async def send_forward_request(
68-
self, request: FastApiRequest, path: str, *, query_params: dict[str, Any] | None = None
70+
self,
71+
request: FastApiRequest,
72+
path: str,
6973
) -> HttpxResponse:
7074
"""
7175
Send a forward request to the facts service.
7276
:param request: FastAPI request
7377
:param path: Backend facts service path to forward to
7478
:return: HTTPX response
7579
"""
76-
forward_request = await self.build_forward_request(request, path, query_params=query_params)
80+
forward_request = await self.build_forward_request(request, path)
7781
return await self.send(forward_request)
7882

7983
@staticmethod

horizon/facts/router.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ async def unassign_user_role(
207207
update_subscriber,
208208
wait_timeout,
209209
path=f"/users/{user_id}/roles",
210-
query_params={"return_deleted": True},
211210
entries_callback=create_role_assignment_data_entries,
212211
timeout_policy=timeout_policy,
213212
)
@@ -246,7 +245,6 @@ async def delete_role_assignment(
246245
update_subscriber,
247246
wait_timeout,
248247
path="/role_assignments",
249-
query_params={"return_deleted": True},
250248
entries_callback=create_role_assignment_data_entries,
251249
timeout_policy=timeout_policy,
252250
)
@@ -341,13 +339,12 @@ async def forward_request_then_wait_for_update(
341339
wait_timeout: float | None,
342340
*,
343341
path: str,
344-
query_params: dict[str, Any] | None = None,
345342
update_id: UUID | None = None,
346343
entries_callback: Callable[[FastApiRequest, dict[str, Any], UUID | None], Iterable[DataSourceEntry]],
347344
timeout_policy: TimeoutPolicy = TimeoutPolicy.IGNORE,
348345
) -> Response:
349346
_update_id = update_id or uuid4()
350-
response = await client.send_forward_request(request, path, query_params=query_params)
347+
response = await client.send_forward_request(request, path)
351348
body = client.extract_body(response)
352349
if body is None:
353350
return client.convert_response(response)

0 commit comments

Comments
 (0)