Skip to content

Adds a request timeout to the sync client, plus two small request fixes - #32

Open
V Anbu chelvan (ZANYANBU) wants to merge 1 commit into
dialpad:masterfrom
ZANYANBU:client-timeout-and-request-fixes
Open

V Anbu chelvan (ZANYANBU) wants to merge 1 commit into
dialpad:masterfrom
ZANYANBU:client-timeout-and-request-fixes

Conversation

@ZANYANBU

Copy link
Copy Markdown

Three small fixes to the hand-written request code in client.py and async_client.py. No generated files are touched.

1. The sync client never times out

DialpadClient calls requests without a timeout, and requests has no default, so a request that never gets an answer blocks the caller forever. AsyncDialpadClient already uses 600 seconds.

Both clients now accept a timeout argument that defaults to the same 600 seconds. timeout=None gives the previous behaviour of the sync client.

2. The caller's headers dict is modified

_raw_request does headers = headers or dict() and then adds Authorization and DP-Company-ID to it. When a caller passes its own dict to request() / iter_request(), that dict is left holding the API token:

headers = {'X-Trace': 'abc'}
dp.request(method='GET', sub_path='/api/v2/users/1', headers=headers)
print(sorted(headers))  # ['Authorization', 'DP-Company-ID', 'X-Trace']

The clients now work on a copy.

3. del client.company_id breaks the client

The deleter removes _company_id, so the next request fails in _raw_request:

AttributeError: 'DialpadClient' object has no attribute '_company_id'

Deleting it now resets it to None.

Tests

test/test_client_requests.py covers each fix for both clients (8 tests). They fail on master and pass with this change.

uv run pytest      # 19 passed, total coverage 98.91%
uv run ruff check  # All checks passed!

The README lists the new timeout argument. I have not bumped the version; happy to if you would like that in this PR.

- DialpadClient sent its requests with no timeout, so a request that never
  got an answer blocked the caller forever. Both clients now take a
  `timeout` argument, defaulting to the 600 seconds the async client
  already used. Passing None restores the old behaviour.
- The Authorization and DP-Company-ID headers were written into the headers
  dict passed in by the caller, which left the caller's dict holding the API
  token. The clients now work on a copy.
- `del client.company_id` removed the underlying attribute, so every later
  request raised AttributeError. Deleting it now resets it to None.
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Central YAML (base), Workspace UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: a1096b10-560e-4c6c-b551-c73fe8aa5c62

📥 Commits

Reviewing files that changed from the base of the PR and between 4beb560 and 211f95c.


📒 Files selected for processing (4)
  • README.md
  • src/dialpad/async_client.py
  • src/dialpad/client.py
  • test/test_client_requests.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.



Adds a 600-second default timeout to both clients, with None disabling the timeout. Both clients preserve caller-provided headers and reset company_id to None when deleted. Updates the README and adds request-plumbing tests.

Overall Judgement: ⚠️ Needs minor changes — Test results and current review findings were not provided, so merge readiness cannot be confirmed.

Walkthrough

Both Dialpad clients now accept a configurable request timeout. Request handling also copies caller-provided headers and sets the stored company ID to None when the property is deleted.

Changes

Client request behavior

Layer / File(s) Summary
Configurable request timeouts
src/dialpad/client.py, src/dialpad/async_client.py, README.md, test/test_client_requests.py
Both clients accept a timeout that defaults to 600 seconds. The synchronous client passes the configured timeout to requests, and the asynchronous client passes it to httpx.AsyncClient. The README and tests cover the default, custom values, and None.
Request headers and company ID
src/dialpad/client.py, src/dialpad/async_client.py, test/test_client_requests.py
Both clients copy supplied headers before adding request headers. Deleting company_id sets it to None; subsequent requests omit the company header.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 211f9

The request-option changes appear ready to merge after normal checks.

Pre-merge checks | Passed 2
✅ Passed checks (2 passed)
Check name Status Explanation
Docs-To-Code Alignment Passed README.md was updated in this PR to document the new timeout constructor option, its 600-second default, and None for indefinite waits. This matches both DialpadClient and AsyncDialpadClient, …
Disabled Test Tracking Passed The pull-request diff adds test/test_client_requests.py and does not skip, xfail, disable, quarantine, comment out, or rename any existing test. No test is neutralized.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant