Skip to content

Add method to fetch Host Metadata#678

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

Add method to fetch Host Metadata#678
hectorcast-db merged 2 commits intomainfrom
hectorcast-db/stack/config-auto-complete-1

Conversation

@hectorcast-db
Copy link
Contributor

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

🥞 Stacked PR

Use this link to review incremental changes.


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

Adds `HostMetadata` and a package-private `getHostMetadata()` on
`DatabricksConfig` for parsing the `/.well-known/databricks-config`
discovery 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.
@hectorcast-db hectorcast-db changed the title Add HostMetadata class and getHostMetadata() Add method to fetch Host Metadata Feb 25, 2026
@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: 678
  • Commit SHA: 403558f95de49b680f8e84f72eecf1efa133e21d

Checks will be approved automatically on success.

Comment on lines +817 to +819
Request request = new Request("GET", url);
Response resp = getHttpClient().execute(request);
if (resp.getStatusCode() != 200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on checking only for 200 vs making it flexible with other status codes 2xx?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the server is returning a valid response, 200 is enough here:

────────────────────────────────────────
Code: 200
Name: OK
Meaning: Request succeeded, body contains the resource
Why it doesn't apply: This is the only valid response — a GET
for a config document should return the document.
────────────────────────────────────────
Code: 201
Name: Created
Meaning: A new resource was created
Why it doesn't apply: Only for POST/PUT that creates a
resource. A read-only GET cannot create anything.
────────────────────────────────────────
Code: 202
Name: Accepted
Meaning: Request accepted for async processing
Why it doesn't apply: Implies the response body is not yet
available — we'd have nothing to parse.
────────────────────────────────────────
Code: 203
Name: Non-Authoritative Information
Meaning: Response from a proxy/cache, not the origin server
Why it doesn't apply: The body might be valid, but this
signals
the data may be stale or transformed. Not something we'd
expect from a well-known endpoint.
────────────────────────────────────────
Code: 204
Name: No Content
Meaning: Success but no body
Why it doesn't apply: The body would be empty —
ObjectMapper.readValue would throw, and a config endpoint
with no config is meaningless.
────────────────────────────────────────
Code: 205
Name: Reset Content
Meaning: Success, client should reset its view
Why it doesn't apply: Intended for form resets in browsers;
has
no semantic meaning for an API client.
────────────────────────────────────────
Code: 206
Name: Partial Content
Meaning: Response is a byte-range chunk
Why it doesn't apply: Only for range requests (Range: header).

We send no Range header, so the server should never return
this.

────────────────────────────────────────
Code: 207
Name: Multi-Status
Meaning: Multiple status codes in a single body (WebDAV)
Why it doesn't apply: WebDAV-specific. Not part of HTTP for a
REST endpoint.
────────────────────────────────────────
Code: 208
Name: Already Reported
Meaning: Resource already listed earlier (WebDAV)
Why it doesn't apply: WebDAV-specific, same as above.
────────────────────────────────────────
Code: 226
Name: IM Used
Meaning: Response is a delta encoding
Why it doesn't apply: Requires the client to send A-IM: header

with a delta-encoding request. We don't

@hectorcast-db hectorcast-db added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 30b5035 Feb 27, 2026
16 checks passed
@hectorcast-db hectorcast-db deleted the hectorcast-db/stack/config-auto-complete-1 branch February 27, 2026 07:39
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