From 062ff1180cf957d3f264f4395adc1414c6996b1d Mon Sep 17 00:00:00 2001 From: CodeLine9 Date: Mon, 20 Apr 2026 07:24:57 +0800 Subject: [PATCH] docs(exceptions): clarify ChunkedEncodingError can result from transient issues The existing docstring only mentions "server sent an invalid chunk" but this error is also raised when the connection is interrupted mid-stream during a chunked response. Added a note about transient network issues and retrying, matching maintainer feedback in #7341. Fixes #7341 --- src/requests/exceptions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/requests/exceptions.py b/src/requests/exceptions.py index 6e71506e96..c511c3c331 100644 --- a/src/requests/exceptions.py +++ b/src/requests/exceptions.py @@ -118,7 +118,12 @@ class InvalidProxyURL(InvalidURL): class ChunkedEncodingError(RequestException): - """The server declared chunked encoding but sent an invalid chunk.""" + """The server declared chunked encoding but sent an invalid chunk. + + This may also be raised when the connection is interrupted mid-stream, + resulting in an incomplete chunked response. Retrying the request may + succeed in cases where the error is caused by a transient network issue. + """ class ContentDecodingError(RequestException, BaseHTTPError):