Resolve client host and credentials from one source#191
Draft
parthban-db wants to merge 1 commit into
Draft
Conversation
|
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. |
Client configuration previously flowed through two independent paths. The generated constructor hard-required options.host (throwing "Host is required."), so new PostgresClient({}) could never fall back to a profile. Separately, when no credentials were passed, transport.ts called defaultCredentials() with no arguments and independently loaded the default profile. A client built for host A could therefore silently authenticate with a token resolved for host B.
This adds @databricks/sdk-core/config exporting resolveClientConfig, which normalizes caller options (host, workspaceId, accountId, profile) into one config whose profile travels with the host. ClientOptions gains an optional profile. defaultCredentials now accepts a profileName to resolve on first use and a host overlaid onto the resolved profile, so credentials authenticate against the same profile and host the client resolved. Every client.ts and transport.ts is regenerated to call resolveClientConfig; new XxxClient({}) no longer throws.
This regen pairs with the universe generator PR ("[SDK-JS] Generate clients that resolve host and credentials from one source") that emits the updated client.ts/transport.ts templates.
This diverges slightly from the Go SDK, which resolves the full Config lazily on the request path via EnsureResolved; the synchronous TS constructor keeps host caller-supplied while threading the profile name to credentials to keep them coupled.
Co-authored-by: Isaac
5207cf7 to
5fe52fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Generated clients now resolve their host and credentials from one source via the new
resolveClientConfig, so the profile travels with the host and the two can no longer drift apart.new XxxClient({})no longer throwsHost is required.and can fall back to a profile.Why
Client config previously flowed through two independent paths: the constructor hard-required
options.host, whiletransport.tscalleddefaultCredentials()with no arguments and independently loaded the default profile. A client built for host A could therefore silently authenticate with a token resolved for host B. Routing both through a single resolved config keeps the host and credentials bound to the same profile.What changed
@databricks/sdk-core/configexportingresolveClientConfig, which normalizeshost,workspaceId,accountId, andprofileinto one config (new./configpackage export).ClientOptionsgains an optionalprofile.defaultCredentialsaccepts aprofileName(resolved on first use) and ahostoverlaid onto the resolved profile, so credentials authenticate against the profile and host the client resolved.client.tsto callresolveClientConfigand drop theHost is required.throw, and everytransport.tsto threadprofileName/hostintodefaultCredentials.Configlazily viaEnsureResolved; the synchronous TS constructor keeps the caller-supplied host while threading the profile name to credentials.client.ts/transport.tstemplates.Validated: build, typecheck, lint, and Vitest unit tests for the new
configanddefault-credentialsmodules pass.