Skip to content

Resolve Lakebase .env values in non-interactive apps init#4740

Draft
pkosiec wants to merge 3 commits intomainfrom
pkosiec/fix-lakebase-env-noninteractive
Draft

Resolve Lakebase .env values in non-interactive apps init#4740
pkosiec wants to merge 3 commits intomainfrom
pkosiec/fix-lakebase-env-noninteractive

Conversation

@pkosiec
Copy link
Member

@pkosiec pkosiec commented Mar 13, 2026

Summary

  • Extract ResolvePostgresValues() from PromptForPostgres() so it can be called from the non-interactive code path
  • After --set values are merged in flags mode, resolve derived postgres fields (host, databaseName, endpointPath) by calling ListPostgresEndpoints and ListPostgresDatabases
  • Fixes empty PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT values in .env when using databricks apps init with --set flags

Repro command

Rebuild the CLI and run:

dbx apps init --name event-registration \
        --features lakebase \
        --set "lakebase.postgres.branch=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr" \
        --set "lakebase.postgres.database=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/databases/db-5vqi-xormgdrr0m" \
        --description "Event registration app with Lakebase" \
        --run none --profile DEFAULT --version 0.20.0

Then see if .env has filled PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT:

DATABRICKS_CONFIG_PROFILE=DEFAULT
PGDATABASE=databricks_postgres
LAKEBASE_ENDPOINT=projects/4de10316-dd6f-4606-878e-fdf3189f6766/branches/br-divine-term-y10rpplr/endpoints/primary
PGHOST=ep-small-sunset-y12mao90.database.us-west-2.staging.cloud.databricks.com
PGPORT=5432
PGSSLMODE=require
DATABRICKS_APP_PORT=8000
DATABRICKS_APP_NAME=event-registration
FLASK_RUN_HOST=localhost

Test plan

  • Existing unit tests pass (go test ./libs/apps/prompt/... ./cmd/apps/...)
  • Manual test: run the repro command above and verify .env has populated values for PGHOST, PGDATABASE, LAKEBASE_ENDPOINT
  • Verify interactive mode still works unchanged

This pull request was AI-assisted by Isaac.

@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 17:10 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 13, 2026

Commit: f282f3a

Run: 23067204309

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 8 7 268 787 6:01
💚​ aws windows 8 7 270 785 4:35
🔄​ aws-ucws linux 2 7 7 364 702 7:26
🔄​ aws-ucws windows 2 7 7 366 700 6:00
💚​ azure linux 2 9 271 785 5:18
🔄​ azure windows 3 1 9 271 783 5:29
🔄​ azure-ucws linux 4 1 9 367 698 7:47
🔄​ azure-ucws windows 2 1 9 371 696 6:53
💚​ gcp linux 2 9 267 788 5:31
💚​ gcp windows 2 9 269 786 6:07
20 interesting tests: 7 flaky, 7 SKIP, 6 RECOVERED
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🔄​ TestAccept 💚​R 💚​R 💚​R 🔄​f 💚​R 🔄​f 🔄​f 🔄​f 💚​R 💚​R
🔄​ TestAccept/bundle/destroy/jobs-and-pipeline ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p
🔄​ TestAccept/bundle/destroy/jobs-and-pipeline/DATABRICKS_BUNDLE_ENGINE=terraform ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 💚​R 💚​R 💚​R 💚​R
💚​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/ssh/connect-serverless-gpu 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s
🔄​ TestAccept/ssh/connection 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🔄​ TestFsCpDirToDirWithOverwriteFlag ✅​p ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f ✅​p ✅​p ✅​p
🔄​ TestFsCpDirToDirWithOverwriteFlag/uc-volumes_to_uc-volumes 🙈​s 🙈​s ✅​p ✅​p 🙈​s 🙈​s 🔄​f ✅​p 🙈​s 🙈​s
Top 20 slowest tests (at least 2 minutes):
duration env testname
3:34 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:15 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:13 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:12 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:11 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:05 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:52 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:52 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:51 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:47 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:45 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:44 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:42 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:37 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:15 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:14 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:12 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:10 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:04 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:02 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

pkosiec added 2 commits March 13, 2026 20:09
When running `databricks apps init` with `--set` flags (non-interactive mode),
the `.env` file had empty values for PGHOST, PGDATABASE, and LAKEBASE_ENDPOINT.
These fields have a `Resolve` property that maps them to values derived from the
selected branch. In interactive mode, `PromptForPostgres()` runs the full
resolution flow, but in non-interactive mode no resolution logic ran.

Extract the resolution logic into a new `ResolvePostgresValues()` function and
call it from the non-interactive path after `--set` values are merged.

Co-authored-by: Isaac
Extract ResolvePostgresValues from PromptForPostgres to reuse resolution
of derived postgres fields (host, databaseName, endpointPath) in the
non-interactive/flags code path. Consolidate CollectResources calls.

Co-authored-by: Isaac
@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from 7538829 to 9f516e6 Compare March 13, 2026 19:09
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:10 — with GitHub Actions Inactive
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:18 — with GitHub Actions Inactive
@pkosiec pkosiec force-pushed the pkosiec/fix-lakebase-env-noninteractive branch from b55fc9b to f282f3a Compare March 13, 2026 19:27
@pkosiec pkosiec temporarily deployed to test-trigger-is March 13, 2026 19:28 — with GitHub Actions Inactive
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