Skip to content

fix: raise APIConnectionError when an async response body read fails - #461

Closed
Harsh23Kashyap wants to merge 1 commit into
togethercomputer:mainfrom
Harsh23Kashyap:fix/async-read-connection-error
Closed

Harsh23Kashyap wants to merge 1 commit into
togethercomputer:mainfrom
Harsh23Kashyap:fix/async-read-connection-error

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown

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_response logged the error and fell through, so the unassigned content variable raised UnboundLocalError instead of a meaningful SDK error. The except aiohttp.ClientError branch now raises error.APIConnectionError, matching the synchronous path and arequest_raw.

Adds tests/unit/test_async_response_errors.py covering the ClientError and ServerTimeoutError read paths. The new tests fail on unpatched code (UnboundLocalError) and pass with this change; the full unit suite passes (210 passed).

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-code-security-scanner

Copy link
Copy Markdown

Broly Security Scan

Warning

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
No vulnerabilities detected in this PR.

Note

Re-scan this PR anytime with /broly scan — useful after /broly undismiss, or to refresh findings without a new push.

Broly — SAST (zai-org/GLM-5.3) · Secrets · SCA · IaC · GH Actions · Base Images · Supply Chain Threats · Exploit Chains · Adversarial Verification

We're continuously improving Broly's accuracy and finding quality — your feedback is valuable. False positives, missed findings, bugs, and feature requests all welcome.

Ask in #security-engineering   Powered by Together AI

@blainekasten

Copy link
Copy Markdown
Contributor

This repo is deprecated and is not taking new patches. Thanks.

The new SDK is hosted at https://github.com/togethercomputer/together-py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants