Skip to content

feat: Replace niquests with httpx - #604

Merged
razor-x merged 8 commits into
betafrom
claude/http-library-options-cxtlwv
Aug 13, 2026
Merged

feat: Replace niquests with httpx#604
razor-x merged 8 commits into
betafrom
claude/http-library-options-cxtlwv

Conversation

@razor-x

@razor-x razor-x commented Aug 12, 2026

Copy link
Copy Markdown
Member

Summary

This PR migrates the SDK from niquests to httpx as the HTTP client library, replacing urllib3's Retry with the httpx-retries package.

niquests depends on urllib3-future, which installs into the urllib3 package namespace and conflicts with packages depending on genuine urllib3 in customer environments (see the LaunchDarkly/gevent report and the HAS_NEVER_CHECK_COMMON_NAME hybrid-install failures). httpx was already in the dependency tree via svix, and its dependency chain does not touch urllib3, so this class of breakage becomes structurally impossible.

Key Changes

  • HTTP Client Migration: Replaced niquests.Session with httpx.Client throughout the codebase

    • Updated SeamHttpClient to inherit from httpx.Client instead of niquests.Session
    • httpx natively supports base_url and client-level timeouts, so the URL-joining and timeout plumbing workarounds are gone
    • Updated exception handling (e.g., niquests.HTTPError → httpx.HTTPStatusError, niquests.exceptions.Timeout → httpx.TimeoutException)
  • Retries via httpx-retries: The retries option now takes an httpx-retries Retry, re-exported as seam.Retry

    • Field names mirror urllib3.util.Retry (total, backoff_factor, status_forcelist, respect_retry_after_header), so migration is a one-line import change
    • Retries are applied through an httpx_retries.RetryTransport wrapping the client transport
    • Known limitation: httpx-retries does not treat POST as retryable, so the retry policy currently has no effect on Seam API requests; the affected tests are marked xfail. A follow-up PR will apply the retry policy to API requests without exposing the HTTP method in the SDK's public API.
  • API Updates:

    • Renamed niquests_options parameter to httpx_options across Seam, SeamWithoutWorkspace, and SeamHttpClient
    • Updated timeout handling to use httpx.Timeout objects
    • Modified paginator to use httpx event_hooks instead of niquests hooks
  • Dependencies: niquests, urllib3-future, and the compiled qh3/jh2 wheels are gone from the lockfile; httpx (already required via svix) and the pure-Python httpx-retries are the only additions. Constraints are kept as permissive as possible (httpx>=0.23.0,<1, matching svix's floor; verified the test suite passes on httpx 0.23.0). Also removed the unused dataclasses-json dependency.

  • Documentation: Updated README with sections for configuring retries and httpx client options

  • Tests: Updated test suite to work with httpx exceptions and behavior

Breaking Changes

  • niquests_optionshttpx_options
  • retries takes seam.Retry (httpx-retries) instead of urllib3.util.Retry
  • Seam.client is an httpx.Client subclass; request errors surface as httpx exceptions
  • Connection errors are no longer retried unless a retries policy is configured

https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1

@razor-x razor-x changed the title Replace niquests with httpx and implement custom retry logic Replace niquests with httpx Aug 12, 2026
@razor-x
razor-x marked this pull request as ready for review August 12, 2026 23:53
@razor-x
razor-x requested a review from a team as a code owner August 12, 2026 23:53
@razor-x razor-x changed the title Replace niquests with httpx feat: Replace niquests with httpx Aug 12, 2026
@razor-x
razor-x force-pushed the claude/http-library-options-cxtlwv branch from df592ce to cbe98fd Compare August 13, 2026 03:30
@razor-x
razor-x changed the base branch from main to beta August 13, 2026 03:30
claude added 8 commits August 13, 2026 04:09
The niquests dependency urllib3-future installs into the urllib3
package namespace, which conflicts with packages depending on genuine
urllib3 in customer environments and cannot be mitigated from the SDK.
httpx is already in the dependency tree via svix and its dependency
chain does not touch urllib3.

BREAKING CHANGE: The niquests_options option is now httpx_options and
is passed to the underlying httpx.Client. The retries option now takes
a seam.Retry instead of a urllib3.util.Retry; the fields mirror the
urllib3 names. Seam.client is now an httpx.Client subclass, and
request errors are raised as httpx exceptions, e.g. httpx.
HTTPStatusError instead of niquests.HTTPError and httpx.
TimeoutException instead of niquests.exceptions.Timeout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
The retries option now takes an httpx_retries.Retry, re-exported as
seam.Retry. Its fields mirror the urllib3.util.Retry names. Unlike the
previous urllib3 default, the default policy does not retry connection
errors for POST requests; pass allowed_methods=["POST"] to opt in to
retrying Seam API requests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
Which HTTP methods the Seam API uses is not part of the SDK's public
API, so a configured retry policy must not require consumers to name
them in allowed_methods.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
Resource classes define their own from_dict on standard library
dataclasses and nothing imports dataclasses_json.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
The SDK is a library, so keep dependency constraints as permissive as
possible. The httpx floor matches svix, and the httpx-retries floor is
the release that introduced Retry.copy_with.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
The retries option should not silently modify the policy it is given.
Since httpx-retries does not treat POST as retryable, the retry policy
currently has no effect on Seam API requests; the affected tests are
marked xfail. A follow-up PR will apply the retry policy to API
requests without exposing the HTTP method in the SDK's public API.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QxwdLpWpFhxSn7mZ2Fb6p1
@razor-x
razor-x force-pushed the claude/http-library-options-cxtlwv branch from 6adc7f5 to d08abb9 Compare August 13, 2026 04:10
@razor-x
razor-x merged commit d635b52 into beta Aug 13, 2026
15 checks passed
@razor-x
razor-x deleted the claude/http-library-options-cxtlwv branch August 13, 2026 04:13
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.

2 participants