acceptance: Preserve ConfigFile in proxy#5612
Conversation
pietern
left a comment
There was a problem hiding this comment.
@simonfaltum Any idea why this might happen?
Probably related to the new handling of default profiles. If the host and token are set, it should not fall back to the default profile though.
Integration test reportCommit: 4b23545
26 interesting tests: 15 SKIP, 7 KNOWN, 4 flaky
Top 24 slowest tests (at least 2 minutes):
|
|
@pietern good catch, and your intuition is right: with host and token set, the config file should be ignored. The SDK already does exactly that ( In In this test it happens because the proxy path dropped I opened #5616 for the underlying product bug: skip default-profile resolution when |
Integration test reportCommit: 9f0ac8d
394 interesting tests: 318 MISS, 41 FAIL, 27 RECOVERED, 4 PANIC, 2 SKIP, 1 KNOWN, 1 flaky
Top 50 slowest tests (at least 2 minutes):
|
…ironment (databricks#5616) ## Why When `DATABRICKS_HOST` and `DATABRICKS_TOKEN` are set in the environment, the CLI was still falling back to the default profile from `.databrickscfg` and merging its credentials with the environment config, so commands could fail with `more than one authorization method configured`. This surfaced on databricks#5612: a cloud proxy run lost `DATABRICKS_CONFIG_FILE`, the CLI subprocess read the developer's real `~/.databrickscfg`, and because that file had `[__settings__].default_profile` set, auth broke even though host and token were provided. ## Why it happens The Go SDK's config-file loader already ignores `.databrickscfg` when a host is configured and no profile is selected, but only while `cfg.Profile` is empty (`configFileLoader.Configure`). The CLI's `resolveDefaultProfile` pins `cfg.Profile` to the default profile before the SDK runs, which defeats that skip-guard: the SDK then loads the profile and merges its credentials with the environment config, producing the conflict. ## Changes Before: `resolveDefaultProfile` (used by `MustWorkspaceClient` and `MustAccountClient`) pinned `cfg.Profile` to the resolved default profile whenever no profile was requested via `--profile` / `DATABRICKS_CONFIG_PROFILE`, regardless of the environment. Now: it returns early when `DATABRICKS_HOST` is set. Authentication is then fully determined by the environment, so an explicit host and token win and the default profile is not pinned. This mirrors the SDK's own behavior. Pinning was only ever needed to keep `cfg.Profile` in sync for the OAuth cache key when the SDK actually reads a profile, which is exactly the case where no host is set in the environment. User-visible effect: `auth describe` with `DATABRICKS_HOST` set now reports `profile: default` instead of the configured `default_profile`, since the environment, not the profile, determines auth. The `cmd/auth/describe/default-profile` acceptance test is updated to reflect this. `cmd/api/api.go` pins the default profile inline with the same gap; that is left for a separate change to keep this PR focused. `cmd/auth/token.go` is intentionally excluded since it resolves which profile to mint a token for. ## Test plan - [x] New unit test `TestMustWorkspaceClientEnvHostSkipsDefaultProfile`: with `DATABRICKS_HOST` + `DATABRICKS_TOKEN` set and a same-host default profile that uses basic auth, the profile is not pinned and auth succeeds. Verified it fails without the fix (`more than one authorization method configured: basic and pat`). - [x] Existing default-profile tests still pass (`cmd/auth/...`, `auth/...`, `cmd/api/...`); `cmd/auth/describe/default-profile` output regenerated. - [x] `./task fmt-q`, `./task checks`, `./task lint-q` clean. This pull request and its description were written by Isaac.
Changes
Preserve ConfigFile
Why
Without it, the config file set to /dev/null by
deco env runisn't respected and falls back to developer's~/.databrickscfg. If that one has[__settings__].default_profileset, calls fail.#5616 attempted to fix this, but if the host is in .databrickscfg with no auth in cache, the token still isn't respected. Once that is solved, we can revert this PR
Tests
deco env run