Skip to content

Commit 4c71557

Browse files
committed
fix: Use configured server_url for split page dummy request
Fixes #191. Due to a limitation in our templated codebase, we need our split page logic to return a request that's just going to give a 200 response. Then, we jump back into the AfterSuccessHook and await all of the pdf splits. Hopefully we can clean this up soon to avoid having an extra call at all, but for now let's make sure the GET /general/docs is done on the correct base url.
1 parent 18a1309 commit 4c71557

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.26.1
2+
3+
### Enhancements
4+
5+
### Features
6+
7+
### Fixes
8+
* Use the configured server_url for our split page "dummy" request
9+
110
## 0.26.0
211

312
### Enhancements

_test_unstructured_client/integration/test_decorators.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,14 @@ async def mock_send(_, request: httpx.Request, **kwargs):
304304
305305
We want to make sure both code paths are retried.
306306
"""
307-
# Assert that the SDK issues our no-op request
307+
# Assert that the SDK issues our dummy request
308308
# returned by the BeforeRequestHook
309309
nonlocal mock_endpoint_called
310-
if request.url.host == "no-op" or "docs" in request.url.path:
310+
if request.url.host == "localhost" and "docs" in request.url.path:
311311
mock_endpoint_called = True
312312
return Response(200, request=request)
313+
elif "docs" in request.url.path:
314+
assert False, "The server URL was not set in the dummy request"
313315

314316
request_body = request.read()
315317

src/unstructured_client/_hooks/custom/split_pdf_hook.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
156156
# # Otherwise, pass the request to the default transport
157157
# return await self.base_transport.handle_async_request(request)
158158

159+
# Instead, save the base url so we can use it for our dummy request
160+
self.base_url = base_url
161+
159162
# Explicit cast to httpx.Client to avoid a typing error
160163
httpx_client = cast(httpx.Client, client)
161164
# async_httpx_client = cast(httpx.AsyncClient, async_client)
@@ -346,7 +349,7 @@ async def call_api_partial(page):
346349
# dummy_request = httpx.Request("GET", "http://no-op")
347350
return httpx.Request(
348351
"GET",
349-
"https://api.unstructuredapp.io/general/docs",
352+
f"{self.base_url}/general/docs",
350353
headers={"operation_id": operation_id},
351354
)
352355

0 commit comments

Comments
 (0)