Skip to content

Surface a re-auth hint when the relayed-proxy 401 refresh fails - #374

Merged
masonc08 merged 1 commit into
mainfrom
masonc08/relayed-refresh-failure-message
Aug 24, 2026
Merged

Surface a re-auth hint when the relayed-proxy 401 refresh fails#374
masonc08 merged 1 commit into
mainfrom
masonc08/relayed-refresh-failure-message

Conversation

@masonc08

Copy link
Copy Markdown
Collaborator

Problem

The relayed Claude Max/Enterprise proxy (gateway_proxy.py) carries two independently-expiring credentials: Claude Code's Anthropic subscription OAuth in Authorization, and a short-lived Databricks token that this proxy mints into X-Databricks-AI-Gateway-Token.

On a 401/403, _ProxyHandler._handle force-refreshes the Databricks swap token and retries once — a stale-access-token 401 self-heals. But when cache.refresh() itself fails (the underlying Databricks OAuth session is dead, not just the access token — e.g. after a long idle/overnight gap), the branch did except RuntimeError: pass, silently swallowing it. The user is then handed a bare relayed 401 with no guidance, which surfaces in Claude Code as a generic auth error → they try /login (which only re-does the Anthropic OAuth) instead of the actual fix, databricks auth login.

Fix

Call the existing _log_refresh_failure(exc) in that branch instead of pass. It already prints the actionable databricks auth login hint to stderr and is designed not to leak tokens. Behavior is otherwise unchanged: we still retry with the existing token and relay whatever comes back.

Testing

  • ruff check passes.
  • No happy-path change: the hint prints only when a 401-triggered forced refresh raises.

This pull request and its description were written by Isaac.

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 <no-reply@databricks.com>
@masonc08
masonc08 marked this pull request as ready for review August 24, 2026 18:18
@masonc08
masonc08 requested a review from rohita5l August 24, 2026 18:18
@masonc08
masonc08 merged commit afeed41 into main Aug 24, 2026
1 of 2 checks passed
@masonc08
masonc08 deleted the masonc08/relayed-refresh-failure-message branch August 24, 2026 18:50
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.

2 participants