Skip to content

Commit 8aa4e7d

Browse files
ai: apply changes for #876 (2 review threads)
Addresses: - #3635989590 at src/databricks/sql/auth/oauth.py:74 - #3635989594 at tests/unit/test_auth.py:254 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 7e3e520 commit 8aa4e7d

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/databricks/sql/auth/oauth.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ def _on_timeout():
206206
msg = (
207207
f"Timed out after {self._redirect_callback_timeout_seconds} "
208208
f"seconds waiting for the OAuth redirect callback at "
209-
f"{redirect_url}. No browser completed the login flow — this "
210-
"is expected in a headless environment (e.g. a notebook or "
211-
"job with no browser). See issue #458."
209+
f"{redirect_url}. The login flow was not completed in time — "
210+
"either the interactive login was not finished within the "
211+
"timeout, or this is a headless environment (e.g. a notebook "
212+
"or job with no browser) where no browser can complete the "
213+
"flow. See issue #458."
212214
)
213215
else:
214216
msg = f"No path parameters were returned to the callback at {redirect_url}"

tests/unit/test_auth.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,18 @@ def test_get_tokens_does_not_hang_when_no_callback_received(
227227
# the test does not depend on a specific port being free. A fixed port
228228
# that happens to be occupied would fail to bind and take the
229229
# can't-find-free-port branch instead of the timeout path we exercise.
230+
# Keep the test fast: shorten the callback wait via the constructor
231+
# keyword (the actual new surface this PR introduces) rather than
232+
# mutating the private attribute after the fact. This also exercises the
233+
# Optional[int] fall-back logic. The production default is minutes; the
234+
# bug is that WITHOUT any bound the wait is infinite.
230235
oauth_manager = OAuthManager(
231236
port_range=[0],
232237
client_id="mock-id",
233238
idp_endpoint=InHouseOAuthEndpointCollection(),
234239
http_client=MagicMock(),
240+
redirect_callback_timeout_seconds=2,
235241
)
236-
# Keep the test fast: shorten the callback wait. The production default
237-
# is minutes; the bug is that WITHOUT any bound the wait is infinite.
238-
oauth_manager._redirect_callback_timeout_seconds = 2
239242

240243
# No callback is ever delivered to the redirect server. Run the flow in
241244
# a daemon thread and join with a wall-clock bound so a regression to

0 commit comments

Comments
 (0)