Add default request timeouts to AuthenticatedClient#7529
Conversation
Prevent unbounded HTTP waits by adding connect_timeout (3.05s) and read_timeout (60s) defaults to session.send(). Callers can override per-connector if needed. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Made-with: Cursor
Greptile SummaryThis PR adds default connect (3.05s) and read (60s) timeouts to
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: c1f5a43 |
Additional Comments (1)
The core behavioral change of this PR — passing Consider adding a focused test: @mock.patch.object(Session, "send")
def test_send_passes_timeout_to_session(
self,
send,
test_authenticated_client,
test_saas_request,
test_config_dev_mode_disabled,
):
test_response = Response()
test_response.status_code = 200
send.return_value = test_response
test_authenticated_client.send(test_saas_request)
send.assert_called_once_with(
mock.ANY,
timeout=(DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT),
)Also worth adding a test for custom timeout values set via the constructor to confirm they are propagated correctly. |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: Adrian Galvan <galvana@uci.edu> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Description Of Changes
Add default connect and read timeouts to
AuthenticatedClient.send()to prevent unbounded HTTP waits that can stall Celery workers indefinitely.Previously,
session.send()was called with notimeoutparameter, meaning therequestslibrary would wait forever for a response. This is particularly problematic for background tasks (e.g., consent webhook processing) where a hung third-party API can block a worker permanently.The change adds two constructor parameters with sensible defaults:
connect_timeout(3.05s) — perrequestslibrary recommendation to avoid TCP retransmission boundary edge casesread_timeout(60s) — generous enough for normal API responses while preventing indefinite waitsFully backward-compatible: all existing callers get the defaults automatically. Connectors that need longer timeouts can override per-instance.
Code Changes
src/fides/api/service/connectors/saas/authenticated_client.py- AddDEFAULT_CONNECT_TIMEOUTandDEFAULT_READ_TIMEOUTconstants, addconnect_timeoutandread_timeoutconstructor parameters, pass timeout tuple tosession.send()Steps to Confirm
test_sending_special_characterswhich hits a real HTTP server through the fullsendpath with the timeout now applied)Pre-Merge Checklist
CHANGELOG.mdupdatedMade with Cursor