Skip to content

Non caught exception NetworkError is raised by httpx #1241

@clemlesne

Description

@clemlesne

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

In some circumstances of faulty network (like on developer laptop, poor VPN, …), httpx raises a NetworkError (ConnectError, ReadError, WriteError, CloseError) exception. This error is related to the network management of the library, but the library do not catch it.

It would be easier to catch NetworkError and to map it to a APIError.

See HTTPX doc for exception handling.

To Reproduce

  1. Run any command involving the remote endpoint
  2. Close / interrupt the network connection a few seconds
  3. See the error

Code snippets

No response

OS

macOS 14.3.1

Python version

Python v3.12.1

Library version

openai v1.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions