Skip to content

fix: apply a default timeout to every HTTP request - #60

Open
codechrl wants to merge 3 commits into
Infisical:mainfrom
codechrl:fix-request-timeout
Open

codechrl wants to merge 3 commits into
Infisical:mainfrom
codechrl:fix-request-timeout

Conversation

@codechrl

@codechrl codechrl commented Sep 7, 2026

Copy link
Copy Markdown

InfisicalRequests called session.get, post, patch and delete without a timeout, so every request ran with the requests default of timeout=None. A server that accepts the connection and never replies leaves the caller blocked with no deadline and no exception. NETWORK_ERRORS already lists ReadTimeout and ConnectTimeout, so those with_retry branches could never be reached.

InfisicalRequests and InfisicalSDKClient now take a timeout parameter that defaults to 30 seconds and is passed to every request. A caller that wants the old behavior passes timeout=None, and one on a slow network can raise it.

No new dependencies. The default applies to existing callers without a code change on their side.

Every session call in InfisicalRequests ran without a timeout argument.
The requests default of timeout=None leaves the socket with no deadline.
A server that accepts a connection and never replies blocks the caller
indefinitely.

NETWORK_ERRORS already lists ReadTimeout and ConnectTimeout, so those
retry branches were unreachable.

Add a timeout parameter to InfisicalRequests and InfisicalSDKClient.
It defaults to 30 seconds and is passed to every request. Passing None
restores the previous behavior.
@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a configurable per-attempt HTTP timeout to the shared SDK transport and propagates it from the public client constructor.

  • Applies the configured timeout to GET, POST, PATCH, and DELETE requests.
  • Prevents write operations from being retried after read timeouts while retaining retries for connection failures.
  • Adds coverage for timeout propagation and method-specific retry behavior.
  • Updates retry tests to mock backoff sleeps and avoid slowing the test suite.

Confidence Score: 5/5

The PR appears safe to merge; the latest change addresses the remaining test-runtime concern without introducing a new actionable issue.

The current code addresses the timeout typing and semantics concerns, avoids replaying writes after read timeouts, and mocks retry backoff in persistent-error tests. All four previous threads were manually resolved without explanatory replies, and no outstanding finding remains.

Important Files Changed

Filename Overview
infisical_sdk/client.py Adds a nullable timeout constructor option, documents its per-attempt semantics, and forwards it to the shared transport.
infisical_sdk/infisical_requests.py Applies the timeout to every HTTP method and excludes read timeouts from write retries to avoid replaying uncertain writes.
tests/test_infisical_requests.py Verifies timeout propagation and retry classification while mocking retry sleeps to keep tests fast.

Reviews (4): Last reviewed commit: "test: mock the retry backoff so the suit..." | Re-trigger Greptile

Comment thread infisical_sdk/infisical_requests.py Resolved
Comment thread infisical_sdk/client.py Resolved
Comment thread infisical_sdk/client.py Resolved
The new default made ReadTimeout reachable for the first time. It is in
NETWORK_ERRORS, and post, patch and delete carry the same retry
decorator as get, so a write whose response was slow would be resent up
to four times after the server may already have applied it.

Writes now retry on a set that excludes ReadTimeout. A connect timeout
still retries on every verb, because the request never reached the
server. A read timeout on a write reaches the caller.

Also annotate the client timeout as Optional[float], since None is a
documented value, and say in the docstring that the value applies to
the connection and to the response on each attempt.
@codechrl
codechrl marked this pull request as draft September 7, 2026 06:54
@codechrl
codechrl marked this pull request as ready for review September 7, 2026 06:54
Comment thread tests/test_infisical_requests.py Resolved
@codechrl

codechrl commented Sep 7, 2026

Copy link
Copy Markdown
Author

@greptileai fixes pushed, please re-review

The retry tests exercised the real exponential backoff, which added
about a minute to the run for no added coverage.
@codechrl

codechrl commented Sep 7, 2026

Copy link
Copy Markdown
Author

@greptileai fixes pushed, please re-review

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