Skip to content

Add support for default_profile in [__settings__] section#698

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

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

Conversation

@simonfaltum
Copy link
Member

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: After parsing the INI file, if no profile is explicitly set, read [__settings__].default_profile. If present and non-empty, use it as the profile name. If the referenced profile section does not exist, throw the same error as an explicit --profile pointing to a missing section.

DefaultProfileTest.java: 7 test scenarios covering resolution, precedence, legacy fallback, empty settings, explicit override, settings-not-a-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
  • 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.
@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: 5c59decd0db5fe1b500b307310a0847a201b81a7

Checks will be approved automatically on success.

@simonfaltum simonfaltum marked this pull request as ready for review March 11, 2026 20:19
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