Skip to content

Add timeout to requests in oauth.py#1401

Open
renaudhartert-db wants to merge 1 commit intomainfrom
fix/issue-1338-oauth-timeout
Open

Add timeout to requests in oauth.py#1401
renaudhartert-db wants to merge 1 commit intomainfrom
fix/issue-1338-oauth-timeout

Conversation

@renaudhartert-db
Copy link
Copy Markdown
Contributor

Summary

requests.post() and requests.get() calls in databricks/sdk/oauth.py did not pass a timeout= parameter. Because token refresh runs inside session.auth (the header_factory callback), it executes before the SDK's per-request timeout on the underlying requests.Session takes effect. When the OAuth endpoint is unreachable or slow, the calls blocked indefinitely.

This PR adds a default 60s timeout to the three affected call sites:

  • retrieve_token()
  • get_azure_entra_id_workspace_endpoints()
  • PATOAuthTokenExchange.refresh()

Test plan

  • Added three regression tests that patch requests.post/requests.get and assert timeout= is passed at each call site.
  • tests/test_oauth.py passes locally (17 tests).

Fixes #1338

`requests.post()` and `requests.get()` calls in `databricks/sdk/oauth.py`
did not pass a `timeout=` parameter. Because token refresh runs inside
`session.auth` (the `header_factory` callback), it executes before the
SDK's per-request timeout on the underlying `requests.Session` takes
effect. When the OAuth endpoint is unreachable or slow, these calls
blocked indefinitely.

This change adds a default 60s timeout to the three affected call sites:
`retrieve_token()`, `get_azure_entra_id_workspace_endpoints()`, and
`PATOAuthTokenExchange.refresh()`. Tests added to verify the timeout is
passed on each call path.

Fixes #1338

Signed-off-by: Renaud Hartert <renaud.hartert@databricks.com>
@github-actions
Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1401
  • Commit SHA: cffe3451e61db5777c75708e86a049d16fc140bf

Checks will be approved automatically on success.

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.

[ISSUE] requests.post() and requests.get() calls in oauth.py have no timeout, can hang indefinitely

1 participant