Skip to content

[Internal] Add HostType to HostMetadata#747

Draft
tanmay-db wants to merge 8 commits intomainfrom
hosttype-metadata
Draft

[Internal] Add HostType to HostMetadata#747
tanmay-db wants to merge 8 commits intomainfrom
hosttype-metadata

Conversation

@tanmay-db
Copy link
Copy Markdown
Contributor

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

🥞 Stacked PR


Summary

Parses the host_type field from the /.well-known/databricks-config discovery endpoint into
HostMetadata and stores it on DatabricksConfig, so the SDK knows whether a host is a
workspace, account, or unified host without parsing hostnames.

Why

Today, getHostType() infers the host type by prefix-matching the hostname against
accounts. — everything else is classified as WORKSPACE. This cannot detect unified hosts,
which share the same hostname pattern as workspace hosts.

The server-side host_type field is being added to the /.well-known/databricks-config
endpoint, returning "workspace", "account", or "unified". This PR threads that value
into the SDK so it's available for use when getHostType() is updated to prefer
endpoint-resolved values over URL-based inference (PR #749).

What changed

Interface changes

  • HostType.fromApiValue(String) — new static method that normalizes API values
    (workspace, account, unified) to enum constants (WORKSPACE, ACCOUNTS, UNIFIED).
    Case-insensitive. Returns null for unknown values.
  • HostMetadata.getHostType() — new getter for the host_type field parsed from the
    discovery endpoint response.

Behavioral changes

Internal changes

  • DatabricksConfig.resolvedHostType (package-private) stores the host type resolved during
    resolveHostMetadata().
  • DatabricksConfig.getResolvedHostType() / setResolvedHostType() — package-private
    accessor for testing.

How is this tested?

  • HostTypeTest — 7 tests for fromApiValue() normalization (all cases, case-insensitive,
    null, empty, unknown values)
  • DatabricksConfigTest — 5 tests for host type resolution from metadata (populates
    workspace/account/unified, does not overwrite existing, unknown ignored)

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:09 — with GitHub Actions Inactive
@tanmay-db tanmay-db temporarily deployed to test-trigger-is March 30, 2026 15:09 — with GitHub Actions Inactive
@tanmay-db tanmay-db changed the title Add HostType to HostMetadata [Internal] Add HostType to HostMetadata Mar 30, 2026
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/HostType.java
resolve() internally calls tryResolveHostMetadata() which consumes
a fixture from the FixtureServer. Tests that then explicitly call
resolveHostMetadata() need a second fixture registered to avoid
server returning an unexpected response.
resolve() internally calls tryResolveHostMetadata() which already
populates resolvedHostType. Remove the redundant explicit calls
and revert to single fixtures, except for
testResolveHostMetadataDoesNotOverwriteExistingHostType which
genuinely needs a second call to verify no-overwrite behavior.
…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
@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: 747
  • Commit SHA: bbe3c5823725379fa8dd8c9a96e60c8d05332d81

Checks will be approved automatically on success.

@tanmay-db tanmay-db deployed to test-trigger-is April 11, 2026 12:13 — with GitHub Actions Active
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