Skip to content

Add support for default_profile in [__settings__] section#698

Open
simonfaltum wants to merge 5 commits intomainfrom
default-profile
Open

Add support for default_profile in [__settings__] section#698
simonfaltum wants to merge 5 commits intomainfrom
default-profile

Conversation

@simonfaltum
Copy link
Member

@simonfaltum simonfaltum commented Mar 11, 2026

Summary

  • When no profile is explicitly configured, check [__settings__].default_profile in ~/.databrickscfg before falling back to the DEFAULT section
  • Aligns the Java SDK with the CLI's auth switch feature

Profile resolution order:

  1. Explicit profile (--profile flag, env var, or programmatic config)
  2. [__settings__].default_profile (new)
  3. [DEFAULT] section (legacy fallback)

Changes

ConfigLoader.java: Extracted a resolveProfile method that encapsulates all profile resolution logic (explicit, [__settings__].default_profile, DEFAULT fallback). Returns the resolved profile name and whether it is a silent fallback. loadFromConfig no longer needs to know about __settings__ at all, replacing two booleans (hasExplicitProfile, hasDefaultProfileSetting) with a single isFallback flag.

Using __settings__ as a profile name (either via --profile or default_profile) now returns a specific error ("reserved section name") instead of the generic "has no profile configured".

DefaultProfileTest.java: 8 test scenarios covering resolution, precedence, legacy fallback, empty settings, explicit override, settings-not-a-profile (both via default_profile and explicit --profile), and nonexistent profile error.

Test plan

  • default_profile resolves correctly
  • default_profile takes precedence over [DEFAULT]
  • Legacy fallback when no [__settings__]
  • Legacy fallback when default_profile is empty
  • [__settings__] is not treated as a profile (via default_profile)
  • [__settings__] is not treated as a profile (via explicit --profile)
  • Explicit --profile overrides default_profile
  • default_profile pointing to nonexistent section throws error

Adds support for the __settings__ section in .databrickscfg, enabling
default_profile to specify which profile to use when none is explicitly
set. The resolved profile is written back to DatabricksConfig so
downstream consumers (e.g. DatabricksCliCredentialsProvider) see it.

Rejects __settings__ as a profile target to prevent self-referencing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep default_profile resolution aligned with the other SDKs by preserving the resolved profile name and surfacing bad settings targets instead of silently falling back.
@simonfaltum simonfaltum marked this pull request as ready for review March 11, 2026 20:19
Move all profile resolution logic (explicit, __settings__, DEFAULT
fallback) into a single resolveProfile method that returns the
profile name and whether it is a silent fallback. This replaces the
two-boolean pattern (hasExplicitProfile, hasDefaultProfileSetting)
with a clearer isFallback flag, and keeps __settings__ knowledge
out of loadFromConfig entirely.

Also improves error messages when __settings__ is used as a profile
name: now says "reserved section name" instead of the generic
"has no __settings__ profile configured".

Co-authored-by: Isaac
@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: 698
  • Commit SHA: d029dd287ca67f942da348117dd5a3dcdd16f625

Checks will be approved automatically on success.

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