Skip to content

Commit 91e698e

Browse files
ai: apply changes for #876 (1 review thread)
Addresses: - #3636374430 at src/databricks/sql/auth/oauth.py:215 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent ead14dd commit 91e698e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/databricks/sql/auth/oauth.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,22 @@ def _on_timeout():
205205
self.redirect_port = port
206206
break
207207
except OSError as e:
208+
# Record every bind-time OSError so the fall-through
209+
# `raise last_error` below always re-raises a real exception.
210+
# If we only recorded the port-in-use case, an unexpected error
211+
# on every port (e.g. EACCES, EADDRNOTAVAIL) would leave
212+
# last_error == None and turn `raise last_error` into
213+
# `raise None`, masking the real failure with a confusing
214+
# TypeError.
215+
last_error = e
208216
# errno.EADDRINUSE resolves to the platform's value (48 on
209217
# macOS, 98 on Linux), so a port-in-use bind failure is
210-
# recognized cross-platform. Otherwise last_error stays None on
211-
# Linux and `raise last_error` below becomes `raise None`.
218+
# recognized cross-platform and downgraded to an info log while
219+
# we try the next port.
212220
if e.errno == errno.EADDRINUSE:
213221
logger.info(f"Port {port} is in use")
214-
last_error = e
222+
else:
223+
logger.warning(f"Unexpected error binding port {port}: {e}")
215224
except webbrowser.Error as e:
216225
# No browser could be launched at all (webbrowser.get() found no
217226
# runnable browser). This is a strong, reliable headless signal

0 commit comments

Comments
 (0)