Skip to content

auth: stop writing workspace_id = none on --skip-workspace#5338

Merged
simonfaltum merged 3 commits into
mainfrom
simonfaltum/auth-skip-ws-no-rewrite-wsid
May 27, 2026
Merged

auth: stop writing workspace_id = none on --skip-workspace#5338
simonfaltum merged 3 commits into
mainfrom
simonfaltum/auth-skip-ws-no-rewrite-wsid

Conversation

@simonfaltum
Copy link
Copy Markdown
Member

@simonfaltum simonfaltum commented May 27, 2026

Why

databricks auth login --skip-workspace writes a literal workspace_id = none into .databrickscfg when no workspace can be discovered. That string is a CLI-internal sentinel.

Changes

  • Before: --skip-workspace (and "Skip" picked in the interactive workspace prompt) set the in-memory WorkspaceIDNone sentinel, which was then saved to disk as workspace_id = none.
  • Now: both paths leave WorkspaceID empty. SaveToProfile already omits empty fields, so account-only profiles land with no workspace_id key at all. MatchAccountProfiles already treats absent and none identically, so legacy profiles that still have workspace_id = none keep working.

auth.WorkspaceIDNone stays defined for backwards-compatible parsing.

Re-login regression fix: without the sentinel, an account-only profile loads back with WorkspaceID == "", which has the same shape as a fresh login that still needs a workspace pick. Without further changes, databricks auth login --profile foo (no --skip-workspace) would prompt again on every run. Extract shouldPromptWorkspace and treat "existing profile is already account-only" as honoring the user's prior skip choice. Covers both the new (absent workspace_id) and legacy (workspace_id = none) shapes.

Test plan

  • go test ./cmd/auth/... (existing tests, including TestSetHostAndAccountId_WorkspaceIDNoneSentinelInherited)
  • New TestShouldPromptWorkspace table-driven test exercises re-login into legacy and new-shape account-only profiles, a workspace profile, --skip-workspace, and the no-account-id / known-workspace-id short-circuits.
  • go test ./acceptance -run TestAccept/cmd/auth/profiles/spog-account (legacy workspace_id = none profile still parses as account)
  • ./task checks
  • ./task lint-q

When `databricks auth login --skip-workspace` ran on a host with no
discoverable workspace, the in-memory WorkspaceIDNone sentinel was
persisted to .databrickscfg as the literal string `workspace_id = none`.

The sentinel was only needed in-memory to gate the workspace prompt; it
never had a reason to land on disk. SaveToProfile already omits empty
fields, so just leaving WorkspaceID empty produces a clean account-only
profile, and MatchAccountProfiles still recognizes existing legacy
profiles that have `workspace_id = none` for backwards compat.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

eng-dev-ecosystem-bot commented May 27, 2026

Commit: 34a62d2

Run: 26512728629

simonfaltum added a commit that referenced this pull request May 27, 2026
PR #5338 stops writing workspace_id = none on --skip-workspace. After it
lands, new account-only profiles have no workspace_id key at all, so the
"= none" check here misses them. Broaden the detection to fire when
cfg.Profile is set, cfg.AccountID is non-empty, and cfg.WorkspaceID is
either empty or the legacy "none" sentinel. Reword the error to talk
about "no workspace_id set" instead of the literal sentinel.

The cfg.Profile guard keeps env-var-only configs targeting a unified
host out of the rejection path (their workspace APIs are served from
the account host and auth resolves end-to-end).

Co-authored-by: Isaac
… profile

Without writing the "none" sentinel anymore, an account-only profile loads
back with WorkspaceID == "" — the same shape as a fresh login that still
needs a workspace pick. The next `databricks auth login --profile foo`
would prompt again on every run.

Extract shouldPromptWorkspace and treat "existing profile is account-only"
(account_id set, workspace_id empty or the legacy "none" sentinel) as
honoring the user's prior skip choice. Covers both shapes so legacy
profiles keep working alongside new ones.

Co-authored-by: Isaac
Copy link
Copy Markdown
Contributor

@mihaimitrea-db mihaimitrea-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good.

GPT review caught that `shouldPromptWorkspace` honored an existing
account-only profile without checking the account ID matched. Reusing a
profile name against a different account would suppress the workspace
prompt on the new account too. Tighten the check to require
`existingProfile.AccountID == authArguments.AccountID`.

Co-authored-by: Isaac
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 13:02 — with GitHub Actions Inactive
@simonfaltum simonfaltum temporarily deployed to test-trigger-is May 27, 2026 13:02 — with GitHub Actions Inactive
@simonfaltum simonfaltum added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit dd23604 May 27, 2026
23 checks passed
@simonfaltum simonfaltum deleted the simonfaltum/auth-skip-ws-no-rewrite-wsid branch May 27, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants