twilio / twilio/twilio-python

[BUG] AsyncTwilioHttpClient.request does not use self.timeout

Open Beginner friendly
#925 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Python
Stars
2.1k
Forks
815
Avg merge
2d 13h
Merged PRs (30d)
2

Description

Describe the bug

AsyncTwilioHttpClient.request never falls back to self.timeout if timeout is None

Code snippet
        if timeout is not None and timeout <= 0:
            raise ValueError(timeout)

        basic_auth = None
        if auth is not None:
            basic_auth = BasicAuth(login=auth[0], password=auth[1])

        kwargs = {
            "method": method.upper(),
            "url": url,
            "params": params,
            "data": data,
            "headers": headers,
            "auth": basic_auth,
            "timeout": timeout,
            "allow_redirects": allow_redirects,
        }

        self.log_request(kwargs)
        self._test_only_last_response = None

        temp = False
        session = None
        if self.session:
            session = self.session
        else:
            session = ClientSession()
            temp = True
        self._test_only_last_request = TwilioRequest(**kwargs)
        response = await session.request(**kwargs)
Actual behavior

response is passed "timeout": None in kwargs instead of "timeout": self.timeout when no timeout argument is passed

Expected behavior

response is passed "timeout": self.timeout in kwargs when no timeout argument is passed, this is what (sync) TwilioHttpClient does:

        if timeout is None:
            timeout = self.timeout
        elif timeout <= 0:
            raise ValueError(timeout)
twilio-python version

9.10.9

Python version

3

Logs or error messages

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the AsyncTwilioHttpClient.request entry point shown in the issue and compare its timeout handling with TwilioHttpClient.request. Check the existing tests for these clients before making the change. Done means a missing timeout uses self.timeout while nonpositive explicit values still raise ValueError, with coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.