Skip to content

Commit 55b09a8

Browse files
committed
fix
1 parent 30a73f6 commit 55b09a8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

databricks/sdk/config.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,10 @@ def client_type(self) -> ClientType:
406406
return ClientType.WORKSPACE
407407

408408
if host_type == HostType.UNIFIED:
409-
if self.workspace_id:
410-
return ClientType.WORKSPACE
411409
if self.account_id:
412410
return ClientType.ACCOUNT
413-
raise ValueError("Unified host requires account_id or workspace_id to be set")
411+
# Legacy workspace hosts don't have a workspace_id until AFTER the auth is resolved.
412+
return ClientType.WORKSPACE
414413

415414
# Default to workspace for backward compatibility
416415
return ClientType.WORKSPACE
@@ -419,12 +418,10 @@ def client_type(self) -> ClientType:
419418
def is_account_client(self) -> bool:
420419
"""[Deprecated] Use host_type instead.
421420
422-
Determines if this is an account client based on the host URL.
421+
Determines if this config is compatible with an account client based on the host URL and account_id.
423422
"""
424423
if self.experimental_is_unified_host:
425-
raise ValueError(
426-
"is_account_client cannot be used with unified hosts; use host_type or client_type instead"
427-
)
424+
return self.account_id
428425
if not self.host:
429426
return False
430427
return self.host.startswith("https://accounts.") or self.host.startswith("https://accounts-dod.")

tests/integration/test_auth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ def test_wif_workspace(ucacct, env_or_skip, random):
261261
permissions=[iam.WorkspacePermission.ADMIN],
262262
)
263263

264+
# Clean env var
265+
os.environ.pop("DATABRICKS_ACCOUNT_ID", None)
266+
264267
ws = WorkspaceClient(
265268
host=workspace_url,
266269
client_id=sp.application_id,

0 commit comments

Comments
 (0)