Skip to content

Fix configure/launch when ~/.databrickscfg has duplicate hosts#86

Merged
rohita5l merged 4 commits into
mainfrom
fix-duplicate-profile-disambiguation
May 26, 2026
Merged

Fix configure/launch when ~/.databrickscfg has duplicate hosts#86
rohita5l merged 4 commits into
mainfrom
fix-duplicate-profile-disambiguation

Conversation

@rohita5l
Copy link
Copy Markdown
Collaborator

@rohita5l rohita5l commented May 26, 2026

Summary

  • Thread the Databricks CLI profile name through every databricks invocation
    (auth token, auth login --no-browser retry, build_auth_shell_command,
    and the web-search MCP subprocess via DATABRICKS_CONFIG_PROFILE). Only
    run_databricks_login was passing --profile before, so any workspace whose
    ~/.databrickscfg had two profiles (e.g. DEFAULT + a named alias) pointing
    at the same host hit "DEFAULT and <other> match ... Use --profile to specify"
    and could never finish configure or launch.
  • Persist the chosen profile name in state under "profile" so subsequent
    commands and the Claude Code token-refresh hook disambiguate the same way.
    Falls back to find_profile_name_for_host when --workspaces is given a
    bare URL.
  • Add UCODE_DEBUG logging to get_databricks_profiles so 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

  • ~/.databrickscfg with DEFAULT + a named profile pointing at the same
    host: uv run ucode configure reaches AI Gateway verification without
    the "match" error.
  • Same setup: uv run ucode launch claude succeeds; the auth-refresh
    command stored in state includes --profile <name>.
  • --workspaces https://... (bare URL, no profile picker): profile is
    resolved post-login from find_profile_name_for_host and threaded
    through.
  • UCODE_DEBUG=1 uv run ucode configure with no profiles → blank prompt
    appears AND ~/.ucode/debug.log shows
    get_databricks_profiles: returned=0 total=0 pat=0.
  • Web-search MCP inside Claude Code refreshes its token without the
    duplicate-profile error.
  • uv run pytest passes (including the updated test_e2e.py mock that
    now returns (workspace, None)).

rohita5l and others added 2 commits May 26, 2026 09:59
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>
@rohita5l rohita5l requested a review from AarushiShah-db May 26, 2026 14:22
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>
@rohita5l
Copy link
Copy Markdown
Collaborator Author

Fixes #78

@rohita5l rohita5l changed the title Fix duplicate profile disambiguation Fix configure/launch when ~/.databrickscfg has duplicate hosts May 26, 2026
@rohita5l rohita5l merged commit acfdf66 into main May 26, 2026
2 checks passed
@rohita5l rohita5l deleted the fix-duplicate-profile-disambiguation branch May 26, 2026 16:44
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