Skip to content

Make acceptance sethome export an absolute HOME (cross-platform)#5266

Merged
janniklasrose merged 5 commits into
mainfrom
janniklasrose/sethome-absolute
May 19, 2026
Merged

Make acceptance sethome export an absolute HOME (cross-platform)#5266
janniklasrose merged 5 commits into
mainfrom
janniklasrose/sethome-absolute

Conversation

@janniklasrose
Copy link
Copy Markdown
Contributor

@janniklasrose janniklasrose commented May 19, 2026

Follow-up to #5214

sethome exported HOME (and USERPROFILE) as the relative path the caller passed in (typically "./home"). The SDK expands ~/.databrickscfg against $HOME at lookup time, so the moment a test cd's into a child directory the cfg "disappears": helpers like
databrickscfg.GetConfiguredDefaultProfile silently return "" because the relative path no longer points at a real file. That made it easy to write tests that look like they exercise default_profile resolution but actually only succeed because the cfg lookup short-circuits.

Resolve $1 to an absolute path with cd && pwd before exporting. On Git Bash (MSYS) plain pwd returns Unix-style /c/... paths that the native Windows Go binary can't open, so use pwd -W to get the mixed C:/... form. Use the same form for both HOME and USERPROFILE so tests like cmd/completion (which registers $HOME as the [HOME] replacement) match the CLI's USERPROFILE-derived output on Windows.

Regenerate the four affected outputs.

Co-authored-by: Isaac

@janniklasrose janniklasrose marked this pull request as ready for review May 19, 2026 11:23
Base automatically changed from janniklasrose/auth-default-profile to main May 19, 2026 11:30
sethome exported HOME (and USERPROFILE) as the relative path the caller
passed in (typically "./home"). The SDK expands `~/.databrickscfg`
against $HOME at lookup time, so the moment a test cd's into a child
directory, the cfg "disappears": helpers like
databrickscfg.GetConfiguredDefaultProfile silently return "" because
the relative path no longer points at a real file. That made it easy
to write tests that look like they exercise default_profile resolution
but actually only succeed because the cfg lookup short-circuits.

Resolve $1 to an absolute path with `cd && pwd` (portable on
macOS/Linux/Windows-MSYS) before exporting. With this fix, the
acceptance/auth/bundle_default_profile "workspace.profile pinned"
sub-case correctly fails when the Workspace.Profile == "" guard in
cmd/root/bundle.go configureProfile is removed; previously it passed
either way.

Output for the same directory's "Bundle with workspace.host" sub-case
also changes: with the cfg now reachable from the bundle subdir, the
SDK's host-based lookup finds the matching profile and validate
succeeds instead of failing with "default auth: cannot configure
default credentials".

Co-authored-by: Isaac
81d9297 changed sethome to export an absolute HOME so the SDK can
locate ~/.databrickscfg after a test cd's. The SDK now reports paths
relative to the absolute HOME, which surfaces in user-visible output as
[TEST_TMP_DIR]/home/.databrickscfg (or [HOME]/.zshrc where the test
registers a HOME replacement). The four committed outputs predated the
fix and still expected the relative ./home form; regenerated with
./task test-update.

Co-authored-by: Isaac
The previous fix resolved $home with `cd && pwd` to give HOME and
USERPROFILE an absolute path. On Git Bash (MSYS), plain `pwd` returns
Unix-style /c/... paths that the native Windows Go binary can't open,
so the SDK silently fails to load ~/.databrickscfg and tests like
cmd/api/default-profile (no auth resolves) and cmd/api/workspace-id-none
(profile not read; SDK back-fills WorkspaceID from host metadata) fail
on Windows only.

Use `pwd -W` for USERPROFILE on MSYS/Cygwin to emit the mixed C:/...
form Windows file APIs accept. HOME keeps the Unix-style path bash
itself wants.

Co-authored-by: Isaac
The absolute-path resolution (cd && pwd) introduced in 81d9297 works
on macOS/Linux but emits Unix-style /c/... paths on Git Bash, which the
native Windows Go binary can't open; the follow-up adb452f fixed the
CLI path with `pwd -W` but broke tests like cmd/completion that compare
the bash $HOME placeholder against the CLI's USERPROFILE-derived output.

Revert sethome to the original simple form and restore the four
outputs regenerated in f893006 to their pre-fix relative-./home
forms. bundle_default_profile keeps its sub-cases but the cd'ing
variants short-circuit on a missing cfg again (same expected output as
before 81d9297). A separate PR will revisit the test setup to make
absolute HOME work cleanly across platforms.

Co-authored-by: Isaac
sethome exported HOME (and USERPROFILE) as the relative path the caller
passed in (typically "./home"). The SDK expands `~/.databrickscfg`
against $HOME at lookup time, so the moment a test cd's into a child
directory the cfg "disappears": helpers like
databrickscfg.GetConfiguredDefaultProfile silently return "" because
the relative path no longer points at a real file. That made it easy
to write tests that look like they exercise default_profile resolution
but actually only succeed because the cfg lookup short-circuits.

Resolve $1 to an absolute path with `cd && pwd` before exporting. On
Git Bash (MSYS) plain `pwd` returns Unix-style /c/... paths that the
native Windows Go binary can't open, so use `pwd -W` to get the mixed
C:/... form. Use the same form for both HOME and USERPROFILE so tests
like cmd/completion (which registers `$HOME` as the `[HOME]`
replacement) match the CLI's USERPROFILE-derived output on Windows.

Regenerate the four affected outputs.

Co-authored-by: Isaac
@janniklasrose janniklasrose force-pushed the janniklasrose/sethome-absolute branch from 8cbe33c to b34db38 Compare May 19, 2026 11:50
Comment thread acceptance/auth/bundle_default_profile/output.txt
Comment thread acceptance/auth/bundle_default_profile/output.txt
@janniklasrose janniklasrose added this pull request to the merge queue May 19, 2026
Merged via the queue into main with commit d72afae May 19, 2026
27 checks passed
@janniklasrose janniklasrose deleted the janniklasrose/sethome-absolute branch May 19, 2026 13:22
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