Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of proxies kwarg in httpx==0.28.0 #1902

Closed
1 task done
DJRHails opened this issue Nov 28, 2024 · 12 comments
Closed
1 task done

Use of proxies kwarg in httpx==0.28.0 #1902

DJRHails opened this issue Nov 28, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@DJRHails
Copy link

DJRHails commented Nov 28, 2024

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

httpx version 0.28.0 removes the deprecated proxies argument; this argument is hardcoded in the library at the moment.

To Reproduce

  1. Update to httpx version 0.28.0

Code snippets

  File "/var/lang/lib/python3.10/site-packages/openai/_client.py", line 337, in __init__
    super().__init__(
  File "/var/lang/lib/python3.10/site-packages/openai/_base_client.py", line 1438, in __init__
    self._client = http_client or AsyncHttpxClientWrapper(
  File "/var/lang/lib/python3.10/site-packages/openai/_base_client.py", line 1335, in __init__
    super().__init__(**kwargs)
TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'

OS

macOS

Python version

Python 3.10.12

Library version

openai-1.55.2

@DJRHails DJRHails added the bug Something isn't working label Nov 28, 2024
@stestagg
Copy link

stestagg commented Nov 28, 2024

This is causing a fresh install of openai to be broken currently.

Here's a reproducer: (Dockerfile)

from alpine:edge

RUN apk update
RUN apk add python3 py3-pip

RUN pip install  --break-system-packages openai
RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'

Gives:

 => ERROR [5/5] RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'                              0.4s
------
 > [5/5] RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")':
0.307 Traceback (most recent call last):
0.307   File "<string>", line 1, in <module>
0.307   File "/usr/lib/python3.12/site-packages/openai/_client.py", line 337, in __init__
0.307     super().__init__(
0.307   File "/usr/lib/python3.12/site-packages/openai/_base_client.py", line 1438, in __init__
0.307     self._client = http_client or AsyncHttpxClientWrapper(
0.307                                   ^^^^^^^^^^^^^^^^^^^^^^^^
0.307   File "/usr/lib/python3.12/site-packages/openai/_base_client.py", line 1335, in __init__
0.308     super().__init__(**kwargs)
0.308 TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'
------
Dockerfile:7
--------------------
   5 |
   6 |     RUN pip install  --break-system-packages openai
   7 | >>> RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'
   8 |
--------------------

@Pablo-Merino
Copy link

Having this issue too, with the synchronous client. A temporary fix I've found is to hardcode the httpx version in my requirements to the previous release, which is 0.27.2.

Just adding httpx==0.27.2 makes my code work again.

@dgellow
Copy link
Contributor

dgellow commented Nov 28, 2024

Hi, thank you for the reports, we (@stainless-api) are actively working on a fix.

Edit: we have a patch under review right now and expect to push it to this repo in a few minutes

@RobertCraigie
Copy link
Collaborator

Thanks for the reports, this will be fixed shortly

@dgellow
Copy link
Contributor

dgellow commented Nov 28, 2024

Should be fixed once #1905 gets merged (all the credits to the amazing @RobertCraigie for the quick fix)

@RobertCraigie
Copy link
Collaborator

Sorry for the delay, we're trying to get a hold of someone with the credentials to publish a new release.

Copy link
Contributor

stainless-app bot commented Nov 28, 2024

Fixed by #1905

@vvaezian
Copy link

vvaezian commented Dec 1, 2024

@dgellow @RobertCraigie In the pyproject.toml file, the httpx version is defined as httpx>=0.23.0, <1. Isn't this too wide? It seems to me the dependent libraries versions should only include the current and tested versions. But <1 allows many future upgrades that can potentially break stuff like the current issue. Other dependent libraries are defined in the same manner and seems to have the same issue.

@dgellow
Copy link
Contributor

dgellow commented Dec 2, 2024

Hi @vvaezian, thanks for pointing that out. I tend to agree, though I'm not sure how strict the version range should be in this specific context. That's something we identified and will be discussing today as part of our internal post-mortem for that httpx v0.28.0 incident. I expect we will share an update later today in this thread.

@kristapratico
Copy link
Contributor

@dgellow @RobertCraigie FYI it looks like we need the same fix in the CLI:

http_client = httpx.Client(
proxies=proxies or None,
http2=can_use_http2(),
)

@RobertCraigie
Copy link
Collaborator

ah good catch thank you!

@dgellow
Copy link
Contributor

dgellow commented Dec 5, 2024

@vvaezian Following up on your question, we decided against narrowing the version constraints. Instead we decided to invest into improving our testing setup to be sure we have coverage for nightly/dev versions of httpx (and other core dependencies), before they are released publicly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants