fix: raise APIConnectionError when an async response body read fails - #461
Harsh23Kashyap wants to merge 1 commit into
Conversation
When aiohttp fails to read a non-streaming response body (e.g. the connection drops mid-read), the async interpretation path logged the error and fell through, raising UnboundLocalError on the unassigned content variable instead of a meaningful SDK error. Raise error.APIConnectionError, matching the synchronous path and arequest_raw.
Broly Security ScanWarning Latest baseline snapshot is stale. Broly is running in PR-only fallback mode until the next scheduled baseline refreshes. This does not block the PR. Note ✅ Clean scan Note Re-scan this PR anytime with
|
|
This repo is deprecated and is not taking new patches. Thanks. The new SDK is hosted at https://github.com/togethercomputer/together-py |
Have you read the Contributing Guidelines? Yes
Issue #459
Describe your changes
When aiohttp fails to read a non-streaming response body (e.g. the connection drops mid-read),
_interpret_async_responselogged the error and fell through, so the unassignedcontentvariable raisedUnboundLocalErrorinstead of a meaningful SDK error. Theexcept aiohttp.ClientErrorbranch now raiseserror.APIConnectionError, matching the synchronous path andarequest_raw.Adds
tests/unit/test_async_response_errors.pycovering theClientErrorandServerTimeoutErrorread paths. The new tests fail on unpatched code (UnboundLocalError) and pass with this change; the full unit suite passes (210 passed).