Skip to content

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

Open
tanmay-db wants to merge 13 commits intomainfrom
hosttype-resolved
Open

[Internal] Use resolved host type from host metadata in getHostType()#749
tanmay-db wants to merge 13 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.


Changes

Uses the resolved host type from host metadata as the primary source in getHostType(), falling back to URL pattern matching:

  • Modifies getHostType() to return resolvedHostType when available (set during resolveHostMetadata() from PR [Internal] Add HostType to HostMetadata #747)
  • URL-based pattern matching (accounts. prefix → ACCOUNTS, otherwise → WORKSPACE) is now only used as a fallback when host metadata hasn't been resolved
    yet
  • Makes DatabricksConfigTest and UnifiedHostTest hermetic using FixtureServer

getHostType() priority chain:

  1. resolvedHostType from /.well-known/databricks-config host metadata (highest)
  2. URL pattern matching — accounts. / accounts-dod. prefix → ACCOUNTS (fallback)
  3. Default → WORKSPACE

Tests

  • DatabricksConfigTest: tests for getHostType() returning resolvedHostType when set, including UNIFIED host type
  • UnifiedHostTest: tests for unified host behavior — workspace ID from environment variables, correct host type resolution, hermetic with FixtureServer

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
Update HostMetadata field from single string to List<String> to match
the actual API response format. DatabricksConfig picks the first element
from the list when setting tokenAudience.

Co-authored-by: Isaac
@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: 613e7629bd70ac238d8343e3b0e08adae72a41bd

Checks will be approved automatically on success.

@tanmay-db tanmay-db marked this pull request as ready for review April 13, 2026 13:12
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