1Password / connect-sdk-python

Python SDK for 1Password Connect
https://developer.1password.com/docs/connect
MIT License
200 stars 30 forks source link

'UseClientDefault' object cannot be interpreted as an integer #104

Closed prymeka closed 5 months ago

prymeka commented 5 months ago

Your environment

SDK Version: 1.5.0

Connect Server Version: unk.

OS: Linux (Ubuntu 20.04.6 LTS)

Python Version: 3.12

What happened?

When running in docker, get_item_by_title using new_client_from_environment results in timeout value raising TypeError: 'UseClientDefault' object cannot be interpreted as an integer most likely due to the new get_timeout function returning httpx.USE_CLIENT_DEFAULT (instance of UseClientDefault) when environment variable ENV_CLIENT_REQUEST_TIMEOUT ("OP_CONNECT_CLIENT_REQ_TIMEOUT") is not present.

What did you expect to happen?

No error.

Steps to reproduce

Minimal example:

  1. In Dockerfile:
    FROM python:3.12-slim
    WORKDIR /app
    COPY . /app
    RUN pip install --no-cache-dir onepasswordconnectsdk
    CMD ["python3", "app.py"]
  2. In app.py:
    
    import os 
    from onepasswordconnectsdk.client import new_client_from_environment

os.environ['OP_CONNECT_HOST'] = '...' os.environ['OP_CONNECT_TOKEN'] = '...' client = new_client_from_environment() item_by_title = client.get_item_by_title('...', '...')

3. `docker build -t "test-image" .`
4. `docker container run "test-image"`

## Notes & Logs
<!-- Paste any logs here that may help with debugging.
Remember to remove any sensitive information before sharing! -->
Full traceback:

Traceback (most recent call last):
File "/app/app.py", line 7, in item_by_title = client.get_item_by_title('...', '....') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/onepasswordconnectsdk/client.py", line 156, in get_item_by_title response = self.build_request("GET", url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/onepasswordconnectsdk/client.py", line 374, in build_request response = self.session.request(method, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 821, in request return self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 908, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 936, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 973, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1009, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 218, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request raise exc File "/usr/local/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request response = connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 86, in handle_request raise exc File "/usr/local/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 63, in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 111, in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/backends/sync.py", line 94, in connect_tcp sock = socket.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/socket.py", line 834, in create_connection sock.settimeout(timeout) TypeError: 'UseClientDefault' object cannot be interpreted as an integer


Docker version:

Client: Docker Engine - Community Version: 25.0.4 API version: 1.44 Go version: go1.21.8 Git commit: 1a576c5 Built: Wed Mar 6 16:32:14 2024 OS/Arch: linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 25.0.4 API version: 1.44 (minimum version 1.24) Go version: go1.21.8 Git commit: 061aa95 Built: Wed Mar 6 16:32:14 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.28 GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0

volodymyrZotov commented 5 months ago

Thanks for the reporting! This will be fixed in #102

Meanthile please use previous version v1.4.1