From 7e53242311613863fc54607e899092d31288d4dc Mon Sep 17 00:00:00 2001 From: Mason Cao <32713681+masonc08@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:27:21 +0000 Subject: [PATCH] Surface a re-auth hint when the relayed-proxy 401 refresh fails The retry-on-401 path in the relayed Claude Max/Enterprise proxy force- refreshes the Databricks swap token, but silently swallowed a failed refresh (`except RuntimeError: pass`). When the underlying Databricks OAuth session is fully expired -- not just the access token -- the token can't be re-minted non-interactively, so the user was left with a bare relayed 401 and no guidance. That reads as an Anthropic `/login` prompt and sends the user to the wrong remedy (Claude Code's `/login` only re-does the Anthropic OAuth). Call `_log_refresh_failure` in that branch so the actionable `databricks auth login` hint is printed, then still retry + relay as before. No happy-path behavior change. Co-authored-by: Isaac --- src/ucode/gateway_proxy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ucode/gateway_proxy.py b/src/ucode/gateway_proxy.py index d11b5f1f..de1589df 100644 --- a/src/ucode/gateway_proxy.py +++ b/src/ucode/gateway_proxy.py @@ -242,8 +242,13 @@ def _handle(self) -> None: # instead of surfacing to Claude Code as a spurious Anthropic prompt. try: self.cache.refresh() - except RuntimeError: - pass # refresh failed; retry with the existing token and relay whatever comes + except RuntimeError as exc: + # Refresh failed: the Databricks OAuth session is dead (not just the + # access token) and can't be re-minted non-interactively. Surface the + # `databricks auth login` hint rather than silently relaying a bare 401, + # which otherwise reads as an Anthropic `/login` prompt and sends the + # user to the wrong re-auth. Still retry + relay with the existing token. + _log_refresh_failure(exc) headers = _forwarded_request_headers(self, self.cache.token) with self.client.stream(self.command, url, headers=headers, content=body) as resp: _diagnostic_log(