Skip to content

Honor profile.authType in default credential chain and delegate name()#182

Open
parthban-db wants to merge 1 commit into
mainfrom
parthban-db/stack/bugbash-bug6-authtype-name
Open

Honor profile.authType in default credential chain and delegate name()#182
parthban-db wants to merge 1 commit into
mainfrom
parthban-db/stack/bugbash-bug6-authtype-name

Conversation

@parthban-db
Copy link
Copy Markdown
Contributor

@parthban-db parthban-db commented Jun 3, 2026

🥞 Stacked PR

Use this link to review incremental changes.


Summary

The default credential chain now honors profile.authType, and DefaultCredentials.name() reports the strategy that actually resolved instead of always returning default.

Why

The chain previously tried strategies in a fixed order (PAT, OAuth M2M, Databricks CLI) and stopped at the first applicable one, ignoring profile.authType even though it is parsed from auth_type / DATABRICKS_AUTH_TYPE. A profile that set auth_type = databricks-cli but also carried a token would silently use PAT, with no way to pin a method. Separately, name() was hardcoded to default, so logging and future User-Agent auth= telemetry could never tell which strategy won.

AI Generated

What changed

  • Strategy is now an interface {name, configure} instead of a bare function, so the chain can match a strategy against authType by name (pat, oauth-m2m, databricks-cli) before building it. Converted patStrategy, m2mStrategy, and u2mStrategy to this shape with unchanged config logic.
  • When authType is set, the chain configures only the matching strategy with no fallback: it throws NO_AUTH_CONFIGURED if that strategy cannot configure, and the new AUTH_TYPE_NOT_FOUND code if no strategy matches. When authType is unset, ordered fall-through behavior is unchanged.
  • name() returns default before resolution and the resolved strategy's name afterward.
  • These types are internal (not exported from the package barrel), so this is not a public API change.
  • Mirrors the Go SDK's DefaultCredentials (config/auth_default.go); the JS strategy set is smaller, so fewer authType names are accepted — an existing scope difference. Composing the User-Agent auth= segment is out of scope (JS does not emit one yet).

Validated: npm run build, npm test, npm run test:browser, npm run typecheck, npm run lint, and npm run format:check all pass for @databricks/sdk-auth.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
If this is not necessary for your PR, please include the following in your PR description:
NO_CHANGELOG=true
and rerun the job.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
If this is not necessary for your PR, please include the following in your PR description:
NO_CHANGELOG=true
and rerun the job.

@parthban-db parthban-db force-pushed the parthban-db/stack/bugbash-bug6-authtype-name branch from b69fa83 to 520820d Compare June 4, 2026 13:03
@parthban-db parthban-db marked this pull request as ready for review June 5, 2026 15:39
@parthban-db parthban-db requested a review from Divyansh-db June 5, 2026 15:40
@parthban-db parthban-db force-pushed the parthban-db/stack/bugbash-bug6-authtype-name branch from 520820d to 3d3b3ec Compare June 5, 2026 16:20
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