Skip to content

(py) Streaming read()/aread() hardcode NetworkError, discarding the real timeout/protocol/decode cause #477

Description

@barjin

🤖 Found by Claude ultrareview — automated high-effort code review. Please verify independently before acting.

Location: impit-python/src/response.rs:401 (aread) and :497 (read)

Streaming body reads hardcode ImpitError::NetworkError, discarding the real cause:

let content = response.bytes().await.map(|b| b.to_vec()).map_err(|_| {
    ImpitPyError(impit::errors::ImpitError::NetworkError)
})?;

By contrast, the non-streaming from_async path correctly classifies the error via ImpitError::from(e, None).

Impact: a read-timeout mid-body, a truncated/UnexpectedEof response, or a gzip decode failure all surface to Python as a generic NetworkError with the original cause lost. Callers catching ReadTimeout / RemoteProtocolError / DecodingError will never match.

Suggested direction: use the same ImpitError::from(e, ...) classifier here as the non-streaming path.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working.pythonThis issue is in the Python impit bindings.rustThis issue concerns the Rust part of this monorepo.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions