Skip to content

[Internal] Use resolved host type from host metadata in getHostType()#749

Draft
tanmay-db wants to merge 11 commits intomainfrom
hosttype-resolved
Draft

[Internal] Use resolved host type from host metadata in getHostType()#749
tanmay-db wants to merge 11 commits intomainfrom
hosttype-resolved

Conversation

@tanmay-db
Copy link
Copy Markdown
Contributor

@tanmay-db tanmay-db commented Mar 30, 2026

🥞 Stacked PR

Use this link to review incremental changes.


Summary

getHostType() now returns the host type resolved from host metadata when available, falling
back to URL pattern matching only when metadata has not been resolved.

Why

PRs #747 and #748 added host_type parsing to HostMetadata and store it in
DatabricksConfig.resolvedHostType. However, getHostType() still relied solely on URL
pattern matching. This meant the authoritative signal from the server was ignored.

URL pattern matching is fragile — it can't distinguish unified hosts, and custom or
non-standard URLs may not follow expected patterns. The metadata endpoint is the authoritative
source, so getHostType() should prefer it.

What changed

Interface changes

None. getHostType() still returns HostType with the same possible values.

Behavioral changes

  • getHostType() now returns resolvedHostType when it is not null, taking priority
    over all existing fallback logic (including the experimental unified host flag and URL pattern
    matching).
  • When metadata is unavailable (resolvedHostType == null), behavior is identical to before.

Internal changes

  • Added resolvedHostType check at top of getHostType() in DatabricksConfig.java.
  • Updated javadoc.

How is this tested?

6 new tests in UnifiedHostTest:

  • Metadata workspace overrides account-like URL
  • Metadata account overrides workspace-like URL
  • Metadata unified is returned directly
  • Falls back to URL matching when resolvedHostType is null
  • Metadata overrides experimental unified host flag
  • End-to-end: resolveHostMetadata → getHostType() returns metadata value

NO_CHANGELOG=true

Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
@tanmay-db tanmay-db temporarily deployed to test-trigger-is March 30, 2026 15:10 — with GitHub Actions Inactive
@tanmay-db tanmay-db temporarily deployed to test-trigger-is March 30, 2026 15:10 — with GitHub Actions Inactive
@tanmay-db tanmay-db changed the title Hosttype resolved [Internal] Use resolved host type from host metadata in getHostType() Mar 30, 2026
Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
# Conflicts:
#	databricks-sdk-java/src/main/java/com/databricks/sdk/core/DatabricksConfig.java
#	databricks-sdk-java/src/main/java/com/databricks/sdk/core/HostType.java
#	databricks-sdk-java/src/test/java/com/databricks/sdk/core/UnifiedHostTest.java
…orts

DatabricksConfigTest.java:
- Add second fixture for tests calling both resolve() and
  resolveHostMetadata(), since resolve() internally calls
  tryResolveHostMetadata() consuming the first fixture.
- Replace setExperimentalIsUnifiedHost(true) with host_type in
  metadata response, since PR #720 removed the experimental flag
  check from getHostType().

UnifiedHostTest.java:
- Add missing java.io.IOException import.
- Remove 3 broken header injection tests that asserted
  X-Databricks-Org-Id in authenticate() headers — that header is
  injected at the service impl level, not during authentication.
- Remove stale setExperimentalIsUnifiedHost(true) from remaining
  tests (no-op after PR #720).
- Update javadoc to reflect re-introduced UNIFIED host type.
- Remove redundant explicit resolveHostMetadata() calls since
  resolve() already triggers it internally via tryResolveHostMetadata().
  Revert to single fixtures where the second call was removed.
- Keep double fixture only for testResolveHostMetadataDoesNotOverwriteExistingHostType
  which genuinely needs a second resolveHostMetadata() call.
- Use host_type in metadata response instead of experimentalIsUnifiedHost
  flag (removed by PR #720) to make getClientType() return ACCOUNT.
- testWorkspaceIdFromEnvironmentVariables: use FixtureServer URL
  instead of https://mycompany.databricks.com to avoid hitting
  real /.well-known/databricks-config during resolve().
- testNewWithWorkspaceHost: use FixtureServer URL as workspace host
  instead of https://workspace.cloud.databricks.com.
- Remove unnecessary second fixture from testEndToEndResolveToGetHostType.
…with FixtureServer

Replace real unified.databricks.com hostname with FixtureServer to prevent
host metadata resolution from hitting live servers during tests.

Co-authored-by: Isaac
tanmay-db added a commit that referenced this pull request Apr 11, 2026
…tType()

testResolveHostMetadataFallsBackToAccountIdWhenNoDefaultOidcAudience
relies on resolvedHostType influencing getHostType(), which is only
implemented in PR #749 (hosttype-resolved branch). Moved to that branch.
@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 11, 2026 11:46 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 749
  • Commit SHA: 48a405cfeeb53200651d4bd64a9ac93bb10096ff

Checks will be approved automatically on success.

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.

1 participant