Fix configure/launch when ~/.databrickscfg has duplicate hosts#86
Merged
Conversation
When ~/.databrickscfg has multiple profiles pointing at the same host
(e.g. DEFAULT and an aliased name), `databricks auth token --host <url>`
errors with "DEFAULT and <other> match ... Use --profile to specify which
profile to use" because the CLI refuses to disambiguate from the host
alone. Only run_databricks_login passed --profile; has_valid_databricks_auth,
get_databricks_token, the inline auth login --no-browser retry, and
build_auth_shell_command did not — so a workspace with ambiguous profiles
could never complete configure or launch.
This threads the profile name from the picker through state ("profile" key)
into every downstream CLI invocation, and falls back to find_profile_name_for_host
when configure is given a bare URL via --workspaces. The web-search MCP
subprocess receives the profile via DATABRICKS_CONFIG_PROFILE so the token
refresh inside Claude Code also disambiguates correctly.
Format-only changes in databricks.py, test_agent_gemini.py, test_cli.py, and test_e2e_user_agent.py. In test_e2e.py, update the `_prompt_for_configuration` mock to return `(workspace, None)` so the new tuple contract from this branch is honored. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The configure-time workspace picker silently degrades to a blank URL prompt whenever this returns []. Log each dropout path (subprocess error, non-zero exit, JSON decode, all-PAT) under UCODE_DEBUG so the case can be diagnosed from ~/.ucode/debug.log instead of guessing. Also bump the timeout from 10s to 20s and simplify the dedupe loop. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Author
|
Fixes #78 |
3 tasks
AarushiShah-db
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
databricksinvocation(
auth token,auth login --no-browserretry,build_auth_shell_command,and the web-search MCP subprocess via
DATABRICKS_CONFIG_PROFILE). Onlyrun_databricks_loginwas passing--profilebefore, so any workspace whose~/.databrickscfghad two profiles (e.g.DEFAULT+ a named alias) pointingat the same host hit
"DEFAULT and <other> match ... Use --profile to specify"and could never finish
configureorlaunch."profile"so subsequentcommands and the Claude Code token-refresh hook disambiguate the same way.
Falls back to
find_profile_name_for_hostwhen--workspacesis given abare URL.
UCODE_DEBUGlogging toget_databricks_profilesso the silent"workspace picker degrades to a blank URL prompt" case is diagnosable from
~/.ucode/debug.log(logs subprocess error / non-zero rc / JSON decode /all-PAT counts). Bumped its timeout from 10s to 20s.
Test plan
~/.databrickscfgwithDEFAULT+ a named profile pointing at the samehost:
uv run ucode configurereaches AI Gateway verification withoutthe "match" error.
uv run ucode launch claudesucceeds; the auth-refreshcommand stored in state includes
--profile <name>.--workspaces https://...(bare URL, no profile picker): profile isresolved post-login from
find_profile_name_for_hostand threadedthrough.
UCODE_DEBUG=1 uv run ucode configurewith no profiles → blank promptappears AND
~/.ucode/debug.logshowsget_databricks_profiles: returned=0 total=0 pat=0.duplicate-profile error.
uv run pytestpasses (including the updatedtest_e2e.pymock thatnow returns
(workspace, None)).