Skip to content

Commit 8e89995

Browse files
authored
chore: Manually regenerate SDK (#299)
We have a generate failure because we've pulled `general.py` out for some custom changes. (See #270) This will hit the occasional bump as new code is added to this file upstream. The steps for fixing this: - Remove `general.py` from .genignore - Run speakeasy generate - Stage and commit the autogenerated changes, working around our custom code - Commit without the `.genignore` change I set `gen.yaml` to version 0.41.0. This will cause the next generate job to propagate the new version and publish it.
1 parent b0a005f commit 8e89995

22 files changed

+640
-1137
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.41.0
2+
3+
### Enhancements
4+
5+
### Features
6+
* Provide a base `UnstructuredClientError` to capture every error raised by the SDK. Note that some exceptions such as `SDKError` now have more information in the `message` field. This will impact any users who rely on string matching in their error handling.
7+
8+
### Fixes
9+
110
## 0.37.3
211

312
### Enhancements

_test_contract/platform_api/test_destinations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_list_destinations_5xx_code(
108108
)
109109
requests = httpx_mock.get_requests()
110110
assert len(requests) >= 1
111-
assert excinfo.value.message == "API error occurred"
111+
assert "API error occurred" in excinfo.value.message
112112
assert excinfo.value.status_code == error_status_code
113113

114114

@@ -177,7 +177,7 @@ def test_get_destination_not_found(
177177

178178
requests = httpx_mock.get_requests()
179179
assert len(requests) == 1
180-
assert excinfo.value.message == "API error occurred"
180+
assert "API error occurred" in excinfo.value.message
181181
assert excinfo.value.status_code == 404
182182

183183

_test_contract/platform_api/test_jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_get_job_not_found(
101101
)
102102

103103
assert e.value.status_code == 404
104-
assert e.value.message == "API error occurred"
104+
assert "API error occurred" in e.value.message
105105

106106
requests = httpx_mock.get_requests()
107107
assert len(requests) == 1
@@ -130,7 +130,7 @@ def test_get_job_error(httpx_mock, platform_client: UnstructuredClient, platform
130130
)
131131

132132
assert e.value.status_code == 500
133-
assert e.value.message == "API error occurred"
133+
assert "API error occurred" in e.value.message
134134

135135
requests = httpx_mock.get_requests()
136136
assert len(requests) == 4

_test_contract/platform_api/test_sources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_list_sources_5xx_code(
110110
platform_client.sources.list_sources(request=operations.ListSourcesRequest())
111111
requests = httpx_mock.get_requests()
112112
assert len(requests) >= 1
113-
assert excinfo.value.message == "API error occurred"
113+
assert "API error occurred" in excinfo.value.message
114114
assert excinfo.value.status_code == error_status_code
115115

116116

@@ -176,7 +176,7 @@ def test_get_source_not_found(
176176

177177
requests = httpx_mock.get_requests()
178178
assert len(requests) == 1
179-
assert excinfo.value.message == "API error occurred"
179+
assert "API error occurred" in excinfo.value.message
180180
assert excinfo.value.status_code == 404
181181

182182

_test_contract/platform_api/test_workflows.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from unstructured_client import UnstructuredClient
66
from unstructured_client.models import shared, operations
7-
from unstructured_client.models.errors import SDKError
7+
from unstructured_client.models.errors import UnstructuredClientError
88

99

1010
def test_list_workflows(httpx_mock, platform_client: UnstructuredClient, platform_api_url: str):
@@ -108,10 +108,10 @@ def test_list_workflows_error(
108108
status_code=error_status_code,
109109
)
110110

111-
with pytest.raises(SDKError) as excinfo:
111+
with pytest.raises(UnstructuredClientError) as error:
112112
platform_client.workflows.list_workflows(request=operations.ListWorkflowsRequest())
113-
assert excinfo.value.status_code == error_status_code
114-
assert excinfo.value.message == "API error occurred"
113+
assert error.value.status_code == error_status_code
114+
assert "API error occurred" in error.value.message
115115

116116

117117
def test_create_workflow(httpx_mock, platform_client: UnstructuredClient, platform_api_url: str):

gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ generation:
1414
oAuth2ClientCredentialsEnabled: false
1515
oAuth2PasswordEnabled: false
1616
python:
17-
version: 0.40.0
17+
version: 0.41.0
1818
additionalDependencies:
1919
dev:
2020
deepdiff: '>=6.0'

src/unstructured_client/basesdk.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def do():
249249

250250
if http_res is None:
251251
logger.debug("Raising no response SDK error")
252-
raise errors.SDKError("No response received")
252+
raise errors.NoResponseError("No response received")
253253

254254
logger.debug(
255255
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -270,7 +270,7 @@ def do():
270270
http_res = result
271271
else:
272272
logger.debug("Raising unexpected SDK error")
273-
raise errors.SDKError("Unexpected error occurred")
273+
raise errors.SDKError("Unexpected error occurred", http_res)
274274

275275
return http_res
276276

@@ -321,7 +321,7 @@ async def do():
321321

322322
if http_res is None:
323323
logger.debug("Raising no response SDK error")
324-
raise errors.SDKError("No response received")
324+
raise errors.NoResponseError("No response received")
325325

326326
logger.debug(
327327
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
@@ -342,7 +342,7 @@ async def do():
342342
http_res = result
343343
else:
344344
logger.debug("Raising unexpected SDK error")
345-
raise errors.SDKError("Unexpected error occurred")
345+
raise errors.SDKError("Unexpected error occurred", http_res)
346346

347347
return http_res
348348

0 commit comments

Comments
 (0)