Skip to content

Streaming HTTP errors can raise ResponseNotRead instead of GlobalRouterError #38

@saxon134

Description

@saxon134

GlobalRouter.stream() and stream_async() send requests with stream=True, then pass 4xx/5xx responses directly to error_from_response(). For a real streaming response body, error_from_response() calls response.json()/response.text before the body has been read, so httpx raises ResponseNotRead instead of the SDK's documented GlobalRouterError. Reproduce with a MockTransport returning httpx.Response(400, stream=httpx.ByteStream(b'{"error":{"message":"bad"}}')) and then iterating client.chat.stream(...). Read the response content before normalization, or handle streaming error bodies separately.

File: src/globalrouter/_client.py

Line: 214

Severity: medium

Summary: unread streaming errors in globalrouter.stream

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions