Skip to content

Commit f21dc10

Browse files
committed
Fix auth error preservation and platform-specific DNS golden files
Only synthesize ErrNotWorkspaceClient when the host type is actually wrong (AccountHost). For other auth errors like ErrCannotConfigureDefault, return the original error to preserve actionable error messages. Also add replacement rules for platform-specific DNS resolver details in auth switch/profiles acceptance tests (Linux includes "on 127.0.0.53:53", macOS does not). Co-authored-by: Isaac
1 parent 2c7d6cf commit f21dc10

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
Ignore = [
22
"home"
33
]
4+
5+
# Normalize platform-specific DNS error messages in host metadata warnings.
6+
# Linux includes resolver address (e.g. "on 127.0.0.53:53"), macOS does not.
7+
[[Repls]]
8+
Old = 'dial tcp: lookup (\S+)( on \S+)?: no such host'
9+
New = 'dial tcp: lookup $1: no such host'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
Ignore = [
22
"home"
33
]
4+
5+
# Normalize platform-specific DNS error messages in host metadata warnings.
6+
# Linux includes resolver address (e.g. "on 127.0.0.53:53"), macOS does not.
7+
[[Repls]]
8+
Old = 'dial tcp: lookup (\S+)( on \S+)?: no such host'
9+
New = 'dial tcp: lookup $1: no such host'

cmd/root/auth.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,22 @@ func workspaceClientOrPrompt(ctx context.Context, cfg *config.Config, allowPromp
193193
// ErrNotWorkspaceClient from NewWorkspaceClient (as of v0.125.0, host-type
194194
// validation was removed in favor of host metadata resolution). Use
195195
// HostType() to detect wrong host type, and check for ErrCannotConfigureDefault.
196-
needsPrompt := cfg.HostType() == config.AccountHost ||
197-
errors.Is(err, config.ErrCannotConfigureDefault)
196+
wrongHostType := cfg.HostType() == config.AccountHost
197+
needsPrompt := wrongHostType || errors.Is(err, config.ErrCannotConfigureDefault)
198198

199199
if !needsPrompt {
200200
return w, err
201201
}
202202

203203
if !allowPrompt || !cmdio.IsPromptSupported(ctx) {
204-
// Synthesize ErrNotWorkspaceClient so callers (like MustAnyClient)
205-
// can detect the wrong config type and fall through to account client.
206-
return w, databricks.ErrNotWorkspaceClient
204+
// Only synthesize ErrNotWorkspaceClient for wrong host type so that
205+
// callers like MustAnyClient can fall through to account client.
206+
// For other errors (e.g. ErrCannotConfigureDefault), return the
207+
// original error to preserve actionable error messages.
208+
if wrongHostType {
209+
return w, databricks.ErrNotWorkspaceClient
210+
}
211+
return w, err
207212
}
208213

209214
// Try picking a profile dynamically if the current configuration is not valid.

0 commit comments

Comments
 (0)