Skip to content

Wire HostMetadata discovery into DatabricksConfig#680

Merged
hectorcast-db merged 1 commit intomainfrom
hectorcast-db/stack/config-auto-complete-3
Feb 27, 2026
Merged

Wire HostMetadata discovery into DatabricksConfig#680
hectorcast-db merged 1 commit intomainfrom
hectorcast-db/stack/config-auto-complete-3

Conversation

@hectorcast-db
Copy link
Contributor

@hectorcast-db hectorcast-db commented Feb 25, 2026

🥞 Stacked PR

Use this link to review incremental changes.


Summary

Wires host metadata discovery into DatabricksConfig via a new package-private resolveHostMetadata() helper, mirroring Config._resolve_host_metadata() in the Python SDK.

Why

Users configuring the SDK today have no way to let it auto-discover accountId, workspaceId, or the OIDC endpoint from the host — they must supply each field manually. The discoveryUrl config property already allows providing a direct OIDC discovery URL; resolveHostMetadata() completes the picture by deriving all three fields automatically from the host's /.well-known/databricks-config endpoint.

What changed

Interface changes

  • DatabricksConfig.resolveHostMetadata() (package-private) — Calls getHostMetadata() on the configured host and back-fills accountId, workspaceId, and discoveryUrl (with any {account_id} placeholder substituted) if those fields are not already set. Throws DatabricksException if accountId cannot be resolved or if no oidc_endpoint is present in the metadata.

Behavioral changes

  • resolveHostMetadata() is not called automatically — it is opt-in.
  • Existing fields are never overwritten.

Internal changes

Tests in DatabricksConfigTest:

  • testResolveHostMetadataWorkspacePopulatesAllFields — workspace populates all three fields.
  • testResolveHostMetadataAccountSubstitutesAccountId — account host substitutes {account_id} in the OIDC endpoint.
  • testResolveHostMetadataDoesNotOverwriteExistingFields — existing fields are not overwritten.
  • testResolveHostMetadataRaisesWhenAccountIdUnresolvable — raises when accountId cannot be resolved.
  • testResolveHostMetadataRaisesWhenOidcEndpointMissing — raises when oidc_endpoint is absent.
  • testResolveHostMetadataRaisesOnHttpError — raises when the well-known endpoint returns an error.

How is this tested?

Unit tests in DatabricksConfigTest using FixtureServer.

NO_CHANGELOG=true

github-merge-queue bot pushed a commit that referenced this pull request Feb 27, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/databricks/databricks-sdk-java/pull/678/files)
to review incremental changes.
-
[**stack/config-auto-complete-1**](#678)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/678/files)]
-
[stack/config-auto-complete-2](#679)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/679/files/82fbbc2e5c9b9f38705df9a88ad0b6898d793b82..37e2032fd767f99b0c52b6ea57f60dea92e516e1)]
-
[stack/config-auto-complete-3](#680)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/680/files/adbceef3cc10ffef3e5844fe09f58c210f922f6a..18b73249bb564d01fe237f2464145a2ca025e9b4)]

---------
## Summary

Adds `HostMetadata` and a package-private `getHostMetadata()` on
`DatabricksConfig` for parsing the `/.well-known/databricks-config`
discovery endpoint.

## Why

Databricks hosts expose a standard `/.well-known/databricks-config`
endpoint that returns the OIDC endpoint, account ID, and workspace ID in
a single request. The SDK had no primitive to consume it — OIDC endpoint
discovery was handled entirely through host-type-specific logic that
requires the caller to already know whether the host is a workspace,
account console, or unified host.

This PR introduces the foundational building block: a `HostMetadata`
class and a package-private `getHostMetadata()` on `DatabricksConfig`
that fetches and parses the endpoint. The method returns raw metadata
with no substitution (e.g. `{account_id}` placeholders are left as-is),
keeping it a pure discovery primitive. Callers decide how to interpret
the result.

## What changed

### Interface changes

- **`HostMetadata`** — New class in `com.databricks.sdk.core.oauth` with
fields `oidcEndpoint`, `accountId`, `workspaceId`. Deserialized from
JSON via Jackson.
- **`DatabricksConfig.getHostMetadata()` (package-private)** — Fetches
`{host}/.well-known/databricks-config` and returns a `HostMetadata`.
Throws `DatabricksException` on any HTTP error.

### Behavioral changes

None. No existing code paths are modified.

### Internal changes

Tests in `DatabricksConfigTest` covering the two response shapes
(workspace with static OIDC endpoint, account host with `{account_id}`
template) and the HTTP error path.

## How is this tested?

Unit tests in `DatabricksConfigTest` using `FixtureServer`. Both
workspace and account host response shapes are exercised, plus an HTTP
error case.

NO_CHANGELOG=true
@hectorcast-db hectorcast-db force-pushed the hectorcast-db/stack/config-auto-complete-3 branch 2 times, most recently from 97939ac to 733d3ae Compare February 27, 2026 08:30
@hectorcast-db hectorcast-db force-pushed the hectorcast-db/stack/config-auto-complete-3 branch from 733d3ae to 77e9259 Compare February 27, 2026 08:53
github-merge-queue bot pushed a commit that referenced this pull request Feb 27, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/databricks/databricks-sdk-java/pull/679/files)
to review incremental changes.
-
[**stack/config-auto-complete-2**](#679)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/679/files)]
-
[stack/config-auto-complete-3](#680)
[[Files
changed](https://github.com/databricks/databricks-sdk-java/pull/680/files/3b4e6d886efaf9fdedf7de2a5d356ea7eea18617..733d3aefce14ba9aac8ecc82e694f9c2e85fda3e)]

---------
## Summary

Adds tests covering OIDC endpoint resolution directly from a discovery
URL, exercising the existing `discoveryUrl` config field and the
`getDatabricksOidcEndpoints()` short-circuit path.

## Why

The OIDC discovery URL returned by `/.well-known/databricks-config`
points to a standard OAuth 2.0 authorization server metadata document
(`authorization_endpoint`, `token_endpoint`). The Java SDK already has
`discoveryUrl` (`DATABRICKS_DISCOVERY_URL`) and
`getDatabricksOidcEndpoints()` fetching directly from it when set — this
is the Java equivalent of the Python SDK's `get_endpoints_from_url()`
addition. This PR adds the missing test coverage for those paths.

## What changed

### Interface changes

None. The `discoveryUrl` config field (`DATABRICKS_DISCOVERY_URL`) and
the `getDatabricksOidcEndpoints()` short-circuit were already present in
the Java SDK.

### Behavioral changes

None. No existing code paths are modified.

### Internal changes

- `testDiscoveryUrlFromEnv` — verifies `DATABRICKS_DISCOVERY_URL` env
var is loaded into `discoveryUrl`.
- `testDatabricksOidcEndpointsUsesDiscoveryUrl` — verifies
`getDatabricksOidcEndpoints()` short-circuits to fetch directly from
`discoveryUrl` when set.

## How is this tested?

Unit tests in `DatabricksConfigTest` using `FixtureServer`.

NO_CHANGELOG=true
Adds package-private `resolveHostMetadata()` to `DatabricksConfig`.
When called, it fetches `/.well-known/databricks-config` and back-fills
`accountId`, `workspaceId`, and `discoveryUrl` (with any `{account_id}`
placeholder substituted) if those fields are not already set.

Raises DatabricksException if `accountId` cannot be resolved or if no
`oidc_endpoint` is present in the metadata. Mirrors
`Config._resolve_host_metadata()` in the Python SDK.
@hectorcast-db hectorcast-db force-pushed the hectorcast-db/stack/config-auto-complete-3 branch from 77e9259 to 8b0c7c5 Compare February 27, 2026 10:45
@github-actions
Copy link

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: 680
  • Commit SHA: 8b0c7c55f1191d19e8366281d3ef92ffc68a1f0e

Checks will be approved automatically on success.

@hectorcast-db hectorcast-db added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 8f000b1 Feb 27, 2026
16 checks passed
@hectorcast-db hectorcast-db deleted the hectorcast-db/stack/config-auto-complete-3 branch February 27, 2026 12:05
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.

2 participants