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

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

Closed
prymeka opened this issue Apr 3, 2024 · 1 comment · Fixed by #102
Closed

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

prymeka opened this issue Apr 3, 2024 · 1 comment · Fixed by #102
Labels
bug Something isn't working

Comments

@prymeka
Copy link

prymeka commented Apr 3, 2024

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"]
  1. 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('...', '...')
  1. docker build -t "test-image" .
  2. docker container run "test-image"

Notes & Logs

Full traceback:

Traceback (most recent call last):                                                                                                                                                    
  File "/app/app.py", line 7, in <module>
    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
@prymeka prymeka added the bug Something isn't working label Apr 3, 2024
@volodymyrZotov
Copy link
Contributor

volodymyrZotov commented Apr 3, 2024

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

Meanthile please use previous version v1.4.1

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

Successfully merging a pull request may close this issue.

2 participants