Skip to content

Commit 1f8b096

Browse files
hive-botclaude
andcommitted
fix: report should_retry False for a broken-off streamed body, as released
A connection error, timeout or broken chunked body while a streamed response body is read (document or translation memory export download) raises ConnectionException with should_retry False again, as in the released version. These reads are not retried by the SDK; changing the flag is left to the next major version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 12acdd3 commit 1f8b096

4 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
251251
### Fixed
252252
- A glossary CSV row without a target term now raises a `ValueError` naming
253253
the row; previously a bare `IndexError` (it is still an `IndexError`).
254-
- A connection that is reset or breaks off while the response body is read
255-
is now retried like other connection failures, and raises
254+
- A connection that is reset or breaks off while a non-streamed response body
255+
is read is now retried like other connection failures, and raises
256256
`ConnectionException` with `should_retry` `True` once retries are used up.
257257
`create_developer_key()` is still not retried after it.
258258
- `translate_document_download()` now streams the translated document to
259259
`output_file` in chunks, instead of first reading the whole document into
260260
memory for the debug log.
261261
- A connection reset or timeout while `translate_document_download()` or
262262
`download_translation_memory_export()` reads the downloaded file now raises
263-
`ConnectionException` with `should_retry` `True`, instead of a `requests`
264-
exception.
263+
`ConnectionException`, instead of a `requests` exception.
265264
- HTTP 3xx responses that are not followed as redirects (e.g. 300, 304, or a
266265
redirect without `Location`) now raise `DeepLException` with
267266
`http_status_code`, instead of being parsed as a successful response.

‎deepl/http_client.py‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,13 @@ def iter_response_content(
330330
raise _body_read_exception(e) from e
331331

332332

333-
_RETRYABLE_BODY_READ_ERRORS = (
334-
requests.exceptions.ConnectionError,
335-
requests.exceptions.Timeout,
336-
requests.exceptions.ChunkedEncodingError,
337-
)
338-
339-
340333
def _body_read_exception(
341334
e: requests.exceptions.RequestException,
342335
) -> ConnectionException:
343-
# A reset or timeout is retryable, as in _internal_request.
336+
# Not retried; should_retry False until the next major version.
344337
return ConnectionException(
345338
f"Connection failed while reading response: {e}",
346-
should_retry=isinstance(e, _RETRYABLE_BODY_READ_ERRORS),
339+
should_retry=False,
347340
)
348341

349342

‎tests/offline/test_translate_document.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def test_raises_connection_exception_when_download_connection_breaks(
594594
HANDLE, io.BytesIO(), chunk_size=4
595595
)
596596

597-
assert exc_info.value.should_retry is True
597+
assert exc_info.value.should_retry is False
598598

599599

600600
def test_retries_upload_when_rate_limited(mocked):

‎tests/offline/test_translation_memories.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def test_raises_connection_exception_when_export_download_connection_breaks(
823823
job, io.BytesIO(), chunk_size=2
824824
)
825825

826-
assert exc_info.value.should_retry is True
826+
assert exc_info.value.should_retry is False
827827

828828

829829
def test_raises_when_downloading_export_without_download_url():

0 commit comments

Comments
 (0)