From 33b925f652302cc6236a0518628e0029e9208cb3 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 15:55:47 +0000 Subject: [PATCH 01/11] acc: record that apps import does not inline app.yml The app's app.yml has a plain env value, a valueFrom reference and an unquoted value that YAML reads as a number. Today databricks.yml gets no config and app.yml is kept as is, although the command means to inline it. Co-authored-by: Isaac --- acceptance/apps/import/app-yml/out.test.toml | 1 + acceptance/apps/import/app-yml/output.txt | 59 ++++++++++++++++++++ acceptance/apps/import/app-yml/script | 23 ++++++++ acceptance/apps/import/app-yml/src/app.yml | 10 ++++ acceptance/apps/import/app-yml/test.toml | 1 + 5 files changed, 94 insertions(+) create mode 100644 acceptance/apps/import/app-yml/out.test.toml create mode 100644 acceptance/apps/import/app-yml/output.txt create mode 100644 acceptance/apps/import/app-yml/script create mode 100644 acceptance/apps/import/app-yml/src/app.yml create mode 100644 acceptance/apps/import/app-yml/test.toml diff --git a/acceptance/apps/import/app-yml/out.test.toml b/acceptance/apps/import/app-yml/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/apps/import/app-yml/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/apps/import/app-yml/output.txt b/acceptance/apps/import/app-yml/output.txt new file mode 100644 index 00000000000..40b7767a20e --- /dev/null +++ b/acceptance/apps/import/app-yml/output.txt @@ -0,0 +1,59 @@ + +>>> [CLI] apps import --name myapp --output-dir out +Loading app 'myapp' configuration +Creating bundle configuration +File successfully saved to app.yml +Bundle configuration created at databricks.yml +Binding bundle to existing app +Successfully bound to app 'myapp' +Deploying bundle +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/myapp/default/files... +Files: 2 uploaded, 0 deleted +Resources: 0 created, 0 changed, 0 deleted, 1 unchanged +Bundle deployed successfully +Starting app +✓ Getting the status of the app myapp +✓ App is in RUNNING state +✓ App compute is in ACTIVE state +✓ Deployment succeeded +You can access the app at myapp-123.cloud.databricksapps.com +App started successfully + +✔ App 'myapp' imported to [TEST_TMP_DIR]/out + +You can now deploy changes with: databricks bundle deploy + +>>> ls out +app.yml +databricks.yml + +>>> cat out/databricks.yml +bundle: + name: myapp + +workspace: + host: [DATABRICKS_URL] + +resources: + apps: + app: + name: myapp + description: "" + source_code_path: . + +>>> cat out/app.yml +command: + - python + - app.py +env: + - name: GREETING + value: hello + - name: WAREHOUSE_ID + valueFrom: sql-warehouse + - name: PYTHON_VERSION + value: 3.10 + +=== App config the bundle deploys + +>>> [CLI] bundle validate -o json +null diff --git a/acceptance/apps/import/app-yml/script b/acceptance/apps/import/app-yml/script new file mode 100644 index 00000000000..2d086679554 --- /dev/null +++ b/acceptance/apps/import/app-yml/script @@ -0,0 +1,23 @@ +# apps import of an app whose source has an app.yml with a plain env value, a +# valueFrom reference and an unquoted value that YAML reads as a number. +APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" +$CLI workspace import-dir src "$APP_PATH" > /dev/null +$CLI apps create myapp > /dev/null +$CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null + +trace $CLI apps import --name myapp --output-dir out + +trace ls out + +trace cat out/databricks.yml + +if [ -f out/app.yml ]; then + trace cat out/app.yml +fi + +title "App config the bundle deploys" +cd out +trace $CLI bundle validate -o json | jq '.resources.apps.app.config' +cd .. + +rm -rf out diff --git a/acceptance/apps/import/app-yml/src/app.yml b/acceptance/apps/import/app-yml/src/app.yml new file mode 100644 index 00000000000..91084cc1155 --- /dev/null +++ b/acceptance/apps/import/app-yml/src/app.yml @@ -0,0 +1,10 @@ +command: + - python + - app.py +env: + - name: GREETING + value: hello + - name: WAREHOUSE_ID + valueFrom: sql-warehouse + - name: PYTHON_VERSION + value: 3.10 diff --git a/acceptance/apps/import/app-yml/test.toml b/acceptance/apps/import/app-yml/test.toml new file mode 100644 index 00000000000..c405a40c29b --- /dev/null +++ b/acceptance/apps/import/app-yml/test.toml @@ -0,0 +1 @@ +Badness = "app.yml is meant to be inlined into databricks.yml as the app's config and removed (inlineAppConfigFile in cmd/apps/import.go), but the check runs before the source files are downloaded, so it never finds app.yml: databricks.yml gets no config and app.yml stays." From 094c3ec35191f046c376f290c31a0b8535dea408 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 16:13:27 +0000 Subject: [PATCH 02/11] acc: keep Git Bash from rewriting the /Workspace path in apps import test On Windows, Git Bash turns a leading-/ argument into a Windows path, so import-dir and apps deploy got C:/Program Files/Git/Workspace/... and failed. Disable the conversion for those two commands. Co-authored-by: Isaac --- acceptance/apps/import/app-yml/output.txt | 2 +- acceptance/apps/import/app-yml/script | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/acceptance/apps/import/app-yml/output.txt b/acceptance/apps/import/app-yml/output.txt index 40b7767a20e..b600b58c013 100644 --- a/acceptance/apps/import/app-yml/output.txt +++ b/acceptance/apps/import/app-yml/output.txt @@ -53,7 +53,7 @@ env: - name: PYTHON_VERSION value: 3.10 -=== App config the bundle deploys +=== App config the bundle deploys (app.yml, if kept, is uploaded with the source) >>> [CLI] bundle validate -o json null diff --git a/acceptance/apps/import/app-yml/script b/acceptance/apps/import/app-yml/script index 2d086679554..27a930b40b8 100644 --- a/acceptance/apps/import/app-yml/script +++ b/acceptance/apps/import/app-yml/script @@ -1,9 +1,10 @@ # apps import of an app whose source has an app.yml with a plain env value, a # valueFrom reference and an unquoted value that YAML reads as a number. +# MSYS_NO_PATHCONV keeps Git Bash on Windows from rewriting the /Workspace path. APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" -$CLI workspace import-dir src "$APP_PATH" > /dev/null +MSYS_NO_PATHCONV=1 $CLI workspace import-dir src "$APP_PATH" > /dev/null $CLI apps create myapp > /dev/null -$CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null +MSYS_NO_PATHCONV=1 $CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null trace $CLI apps import --name myapp --output-dir out @@ -15,9 +16,10 @@ if [ -f out/app.yml ]; then trace cat out/app.yml fi -title "App config the bundle deploys" +title "App config the bundle deploys (app.yml, if kept, is uploaded with the source)" cd out trace $CLI bundle validate -o json | jq '.resources.apps.app.config' cd .. + rm -rf out From f30b10b1cfe1a78661bc02a3881d450e26db7b7f Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 16:37:19 +0000 Subject: [PATCH 03/11] acc: normalize the Windows output path in the apps import test Co-authored-by: Isaac --- acceptance/apps/import/app-yml/test.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/acceptance/apps/import/app-yml/test.toml b/acceptance/apps/import/app-yml/test.toml index c405a40c29b..0491f2c2d40 100644 --- a/acceptance/apps/import/app-yml/test.toml +++ b/acceptance/apps/import/app-yml/test.toml @@ -1 +1,6 @@ Badness = "app.yml is meant to be inlined into databricks.yml as the app's config and removed (inlineAppConfigFile in cmd/apps/import.go), but the check runs before the source files are downloaded, so it never finds app.yml: databricks.yml gets no config and app.yml stays." + +# Fix path with reverse slashes in the output for Windows. +[[Repls]] +Old = 'TEST_TMP_DIR]\\out' +New = 'TEST_TMP_DIR]/out' From bf226f94d14e2e51dfec1ac1c63d784d2bc21c41 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 17 Nov 2026 12:22:49 +0000 Subject: [PATCH 04/11] acc: log apps import test setup to LOG.setup and use withdir Co-authored-by: Isaac --- acceptance/apps/import/app-yml/script | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/acceptance/apps/import/app-yml/script b/acceptance/apps/import/app-yml/script index 27a930b40b8..7ff08a0ef38 100644 --- a/acceptance/apps/import/app-yml/script +++ b/acceptance/apps/import/app-yml/script @@ -2,9 +2,9 @@ # valueFrom reference and an unquoted value that YAML reads as a number. # MSYS_NO_PATHCONV keeps Git Bash on Windows from rewriting the /Workspace path. APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" -MSYS_NO_PATHCONV=1 $CLI workspace import-dir src "$APP_PATH" > /dev/null -$CLI apps create myapp > /dev/null -MSYS_NO_PATHCONV=1 $CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null +MSYS_NO_PATHCONV=1 $CLI workspace import-dir src "$APP_PATH" &>> LOG.setup +$CLI apps create myapp &>> LOG.setup +MSYS_NO_PATHCONV=1 $CLI apps deploy myapp --source-code-path "$APP_PATH" &>> LOG.setup trace $CLI apps import --name myapp --output-dir out @@ -17,9 +17,6 @@ if [ -f out/app.yml ]; then fi title "App config the bundle deploys (app.yml, if kept, is uploaded with the source)" -cd out -trace $CLI bundle validate -o json | jq '.resources.apps.app.config' -cd .. - +withdir out trace $CLI bundle validate -o json | jq '.resources.apps.app.config' rm -rf out From 1dda6cd5fc19a73eeedb3bf784542e081db10e9c Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 17 Nov 2026 12:31:32 +0000 Subject: [PATCH 05/11] acc: use >> ... 2>&1 instead of &>> in the apps import test macOS runners have bash 3.2, which has no &>>. Co-authored-by: Isaac --- acceptance/apps/import/app-yml/script | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/acceptance/apps/import/app-yml/script b/acceptance/apps/import/app-yml/script index 7ff08a0ef38..c7446d0ff09 100644 --- a/acceptance/apps/import/app-yml/script +++ b/acceptance/apps/import/app-yml/script @@ -2,9 +2,9 @@ # valueFrom reference and an unquoted value that YAML reads as a number. # MSYS_NO_PATHCONV keeps Git Bash on Windows from rewriting the /Workspace path. APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" -MSYS_NO_PATHCONV=1 $CLI workspace import-dir src "$APP_PATH" &>> LOG.setup -$CLI apps create myapp &>> LOG.setup -MSYS_NO_PATHCONV=1 $CLI apps deploy myapp --source-code-path "$APP_PATH" &>> LOG.setup +MSYS_NO_PATHCONV=1 $CLI workspace import-dir src "$APP_PATH" >> LOG.setup 2>&1 +$CLI apps create myapp >> LOG.setup 2>&1 +MSYS_NO_PATHCONV=1 $CLI apps deploy myapp --source-code-path "$APP_PATH" >> LOG.setup 2>&1 trace $CLI apps import --name myapp --output-dir out From 66dbe001773e6d69336e56a4b763281f219bd84d Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Sun, 15 Nov 2026 09:17:04 +0000 Subject: [PATCH 06/11] Add acceptance test for apps import with app.yml Records current behavior: app.yml is not inlined into databricks.yml. Co-authored-by: Isaac --- .../apps/import/app-yml-inlined/out.test.toml | 1 + .../apps/import/app-yml-inlined/output.txt | 42 +++++++++++++++++++ acceptance/apps/import/app-yml-inlined/script | 14 +++++++ .../apps/import/app-yml-inlined/src/app.yml | 4 ++ 4 files changed, 61 insertions(+) create mode 100644 acceptance/apps/import/app-yml-inlined/out.test.toml create mode 100644 acceptance/apps/import/app-yml-inlined/output.txt create mode 100644 acceptance/apps/import/app-yml-inlined/script create mode 100644 acceptance/apps/import/app-yml-inlined/src/app.yml diff --git a/acceptance/apps/import/app-yml-inlined/out.test.toml b/acceptance/apps/import/app-yml-inlined/out.test.toml new file mode 100644 index 00000000000..18b1a88417e --- /dev/null +++ b/acceptance/apps/import/app-yml-inlined/out.test.toml @@ -0,0 +1 @@ +Cloud = false diff --git a/acceptance/apps/import/app-yml-inlined/output.txt b/acceptance/apps/import/app-yml-inlined/output.txt new file mode 100644 index 00000000000..bfb73e66bf6 --- /dev/null +++ b/acceptance/apps/import/app-yml-inlined/output.txt @@ -0,0 +1,42 @@ + +>>> [CLI] apps import --name myapp --output-dir out +Loading app 'myapp' configuration +Creating bundle configuration +File successfully saved to app.yml +Bundle configuration created at databricks.yml +Binding bundle to existing app +Successfully bound to app 'myapp' +Deploying bundle +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/myapp/default/files... +Files: 2 uploaded, 0 deleted +Resources: 0 created, 0 changed, 0 deleted, 1 unchanged +Bundle deployed successfully +Starting app +✓ Getting the status of the app myapp +✓ App is in RUNNING state +✓ App compute is in ACTIVE state +✓ Deployment succeeded +You can access the app at myapp-123.cloud.databricksapps.com +App started successfully + +✔ App 'myapp' imported to [TEST_TMP_DIR]/out + +You can now deploy changes with: databricks bundle deploy + +>>> ls out +app.yml +databricks.yml + +>>> cat out/databricks.yml +bundle: + name: myapp + +workspace: + host: [DATABRICKS_URL] + +resources: + apps: + app: + name: myapp + description: "" + source_code_path: . diff --git a/acceptance/apps/import/app-yml-inlined/script b/acceptance/apps/import/app-yml-inlined/script new file mode 100644 index 00000000000..00de356d1ea --- /dev/null +++ b/acceptance/apps/import/app-yml-inlined/script @@ -0,0 +1,14 @@ +# Test: apps import of an app whose source contains app.yml. +# Expected: app.yml contents are inlined into databricks.yml as `config` and app.yml is removed. +APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" +$CLI workspace import-dir src "$APP_PATH" > /dev/null +$CLI apps create myapp > /dev/null +$CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null + +trace $CLI apps import --name myapp --output-dir out + +trace ls out + +trace cat out/databricks.yml + +rm -rf out diff --git a/acceptance/apps/import/app-yml-inlined/src/app.yml b/acceptance/apps/import/app-yml-inlined/src/app.yml new file mode 100644 index 00000000000..9b32aa601a6 --- /dev/null +++ b/acceptance/apps/import/app-yml-inlined/src/app.yml @@ -0,0 +1,4 @@ +command: ["python", "app.py"] +env: + - name: GREETING + value: hello From b1f741574ed4bbb97a30873e870d9feacd149970 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Sun, 15 Nov 2026 09:27:48 +0000 Subject: [PATCH 07/11] apps import: inline app.yml after downloading source files generateAppBundle looked for app.yml/app.yaml before the downloader had written the app source to disk, so the config was never inlined into databricks.yml and app.yml was left in place. Download first, and build the inlined config as an ordered mapping so the output is deterministic. Co-authored-by: Isaac --- .../cli/apps-import-inline-app-yml.md | 1 + .../apps/import/app-yml-inlined/output.txt | 14 ++++++++--- cmd/apps/import.go | 23 ++++++++++--------- 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 .nextchanges/cli/apps-import-inline-app-yml.md diff --git a/.nextchanges/cli/apps-import-inline-app-yml.md b/.nextchanges/cli/apps-import-inline-app-yml.md new file mode 100644 index 00000000000..831f8cd3289 --- /dev/null +++ b/.nextchanges/cli/apps-import-inline-app-yml.md @@ -0,0 +1 @@ +* Fix `databricks apps import` to inline the app's `app.yml`/`app.yaml` into `databricks.yml` as `config`; previously the file was checked before it was downloaded, so it was never inlined. diff --git a/acceptance/apps/import/app-yml-inlined/output.txt b/acceptance/apps/import/app-yml-inlined/output.txt index bfb73e66bf6..69ca03b4b59 100644 --- a/acceptance/apps/import/app-yml-inlined/output.txt +++ b/acceptance/apps/import/app-yml-inlined/output.txt @@ -3,13 +3,15 @@ Loading app 'myapp' configuration Creating bundle configuration File successfully saved to app.yml +Inlined and removed app.yml Bundle configuration created at databricks.yml Binding bundle to existing app Successfully bound to app 'myapp' Deploying bundle Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/myapp/default/files... -Files: 2 uploaded, 0 deleted -Resources: 0 created, 0 changed, 0 deleted, 1 unchanged +Updated apps.app +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged Bundle deployed successfully Starting app ✓ Getting the status of the app myapp @@ -24,7 +26,6 @@ App started successfully You can now deploy changes with: databricks bundle deploy >>> ls out -app.yml databricks.yml >>> cat out/databricks.yml @@ -37,6 +38,13 @@ workspace: resources: apps: app: + config: + command: + - python + - app.py + env: + - name: GREETING + value: hello name: myapp description: "" source_code_path: . diff --git a/cmd/apps/import.go b/cmd/apps/import.go index 7df83287871..76eb115cedd 100644 --- a/cmd/apps/import.go +++ b/cmd/apps/import.go @@ -439,6 +439,12 @@ func generateAppBundle(ctx context.Context, w *databricks.WorkspaceClient, app * return "", fmt.Errorf("failed to convert app to value: %w", err) } + // Download the app source files before inlining, since app.yml is part of them + err = downloader.FlushToDisk(ctx, false) + if err != nil { + return "", fmt.Errorf("failed to download app source: %w", err) + } + // Check for app.yml or app.yaml and inline its contents appConfigFile, err := inlineAppConfigFile(&v) if err != nil { @@ -473,12 +479,6 @@ func generateAppBundle(ctx context.Context, w *databricks.WorkspaceClient, app * }, []diag.Location{{Line: 20}}), } - // Download the app source files - err = downloader.FlushToDisk(ctx, false) - if err != nil { - return "", fmt.Errorf("failed to download app source: %w", err) - } - // Save databricks.yml databricksYml := filepath.Join(".", "databricks.yml") saver := yamlsaver.NewSaver() @@ -587,7 +587,8 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { newPairs = append(newPairs, appMap.Pairs()...) // Create config section - configMap := make(map[string]dyn.Value) + // Ordered pairs (not a Go map) so the generated YAML is deterministic. + var configPairs []dyn.Pair // Add command if present if cmd, ok := appConfig["command"]; ok { @@ -595,7 +596,7 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { if err != nil { return "", fmt.Errorf("failed to convert command: %w", err) } - configMap["command"] = cmdValue + configPairs = append(configPairs, dyn.Pair{Key: dyn.V("command"), Value: cmdValue}) } // Add env if present @@ -604,14 +605,14 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { if err != nil { return "", fmt.Errorf("failed to convert env: %w", err) } - configMap["env"] = envValue + configPairs = append(configPairs, dyn.Pair{Key: dyn.V("env"), Value: envValue}) } // Add the config section if we have any items - if len(configMap) > 0 { + if len(configPairs) > 0 { newPairs = append(newPairs, dyn.Pair{ Key: dyn.V("config"), - Value: dyn.V(configMap), + Value: dyn.V(dyn.NewMappingFromPairs(configPairs)), }) } From 208e1d5efda99e3944c3a403b8932c08f849f96f Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 09:20:54 +0000 Subject: [PATCH 08/11] Shorten changelog fragment Co-authored-by: Isaac --- .nextchanges/cli/apps-import-inline-app-yml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/cli/apps-import-inline-app-yml.md b/.nextchanges/cli/apps-import-inline-app-yml.md index 831f8cd3289..c25ad800f3c 100644 --- a/.nextchanges/cli/apps-import-inline-app-yml.md +++ b/.nextchanges/cli/apps-import-inline-app-yml.md @@ -1 +1 @@ -* Fix `databricks apps import` to inline the app's `app.yml`/`app.yaml` into `databricks.yml` as `config`; previously the file was checked before it was downloaded, so it was never inlined. +* Fix `databricks apps import` not inlining the app's `app.yml` into `databricks.yml`. From 61203231b3dde049cc585dfc482c169d29bafa63 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 10:30:03 +0000 Subject: [PATCH 09/11] Add PR link to changelog fragment Co-authored-by: Isaac --- .nextchanges/cli/apps-import-inline-app-yml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/cli/apps-import-inline-app-yml.md b/.nextchanges/cli/apps-import-inline-app-yml.md index c25ad800f3c..eae9a05376f 100644 --- a/.nextchanges/cli/apps-import-inline-app-yml.md +++ b/.nextchanges/cli/apps-import-inline-app-yml.md @@ -1 +1 @@ -* Fix `databricks apps import` not inlining the app's `app.yml` into `databricks.yml`. +* Fix `databricks apps import` not inlining the app's `app.yml` into `databricks.yml`. ([#7675](https://github.com/databricks/cli/pull/7675)) From 676e023889772c63ea72e9a7e8bc73fbc472b320 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 13:24:02 +0000 Subject: [PATCH 10/11] apps import: keep app.yml key order when inlining app.yml was parsed into map[string]any, so the keys inside env entries (and resources) came out in random order. Load it as a dyn.Value instead; the YAML saver orders keys by source line. Co-authored-by: Isaac --- cmd/apps/import.go | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/cmd/apps/import.go b/cmd/apps/import.go index 76eb115cedd..48137fdc2ef 100644 --- a/cmd/apps/import.go +++ b/cmd/apps/import.go @@ -2,6 +2,7 @@ package apps import ( "bufio" + "bytes" "cmp" "context" "errors" @@ -12,8 +13,6 @@ import ( "slices" "strings" - "go.yaml.in/yaml/v3" - "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/generate" "github.com/databricks/cli/bundle/phases" @@ -27,7 +26,7 @@ import ( "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" - "github.com/databricks/cli/libs/dyn/convert" + "github.com/databricks/cli/libs/dyn/yamlloader" "github.com/databricks/cli/libs/dyn/yamlsaver" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/logdiag" @@ -567,9 +566,9 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { return "", nil } - // Parse the app config - var appConfig map[string]any - err = yaml.Unmarshal(appConfigData, &appConfig) + // Load into a dyn.Value rather than map[string]any: the saver orders mapping keys by + // source line, so env entries keep the key order they have in the file. + appConfig, err := yamlloader.LoadYAML(appConfigFile, bytes.NewReader(appConfigData)) if err != nil { return "", fmt.Errorf("failed to parse %s: %w", appConfigFile, err) } @@ -590,22 +589,13 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { // Ordered pairs (not a Go map) so the generated YAML is deterministic. var configPairs []dyn.Pair - // Add command if present - if cmd, ok := appConfig["command"]; ok { - cmdValue, err := convert.FromTyped(cmd, dyn.NilValue) - if err != nil { - return "", fmt.Errorf("failed to convert command: %w", err) - } - configPairs = append(configPairs, dyn.Pair{Key: dyn.V("command"), Value: cmdValue}) + // The top-level values drop their app.yml locations so that the saver keeps them in + // insertion order; their contents keep the locations that order nested keys. + if cmd := appConfig.Get("command"); cmd.IsValid() { + configPairs = append(configPairs, dyn.Pair{Key: dyn.V("command"), Value: cmd.WithLocations(nil)}) } - - // Add env if present - if env, ok := appConfig["env"]; ok { - envValue, err := convert.FromTyped(env, dyn.NilValue) - if err != nil { - return "", fmt.Errorf("failed to convert env: %w", err) - } - configPairs = append(configPairs, dyn.Pair{Key: dyn.V("env"), Value: envValue}) + if env := appConfig.Get("env"); env.IsValid() { + configPairs = append(configPairs, dyn.Pair{Key: dyn.V("env"), Value: env.WithLocations(nil)}) } // Add the config section if we have any items @@ -617,14 +607,10 @@ func inlineAppConfigFile(appValue *dyn.Value) (string, error) { } // Add resources at top level if present - if resources, ok := appConfig["resources"]; ok { - resourcesValue, err := convert.FromTyped(resources, dyn.NilValue) - if err != nil { - return "", fmt.Errorf("failed to convert resources: %w", err) - } + if resources := appConfig.Get("resources"); resources.IsValid() { newPairs = append(newPairs, dyn.Pair{ Key: dyn.V("resources"), - Value: resourcesValue, + Value: resources.WithLocations(nil), }) } From d7fdb6b08404ccd79fc8e757b371a6600a878728 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Mon, 16 Nov 2026 15:57:49 +0000 Subject: [PATCH 11/11] acc: show what inlining app.yml does to the recorded app Replace the app-yml-inlined test with the app-yml test from the test-only PR. Its golden diff shows inlining now runs, and its Badness records that valueFrom entries lose their value and unquoted values are re-typed. Co-authored-by: Isaac --- .../apps/import/app-yml-inlined/out.test.toml | 1 - .../apps/import/app-yml-inlined/output.txt | 50 -------------- acceptance/apps/import/app-yml-inlined/script | 14 ---- .../apps/import/app-yml-inlined/src/app.yml | 4 -- acceptance/apps/import/app-yml/output.txt | 68 ++++++++++++++----- acceptance/apps/import/app-yml/test.toml | 2 +- 6 files changed, 53 insertions(+), 86 deletions(-) delete mode 100644 acceptance/apps/import/app-yml-inlined/out.test.toml delete mode 100644 acceptance/apps/import/app-yml-inlined/output.txt delete mode 100644 acceptance/apps/import/app-yml-inlined/script delete mode 100644 acceptance/apps/import/app-yml-inlined/src/app.yml diff --git a/acceptance/apps/import/app-yml-inlined/out.test.toml b/acceptance/apps/import/app-yml-inlined/out.test.toml deleted file mode 100644 index 18b1a88417e..00000000000 --- a/acceptance/apps/import/app-yml-inlined/out.test.toml +++ /dev/null @@ -1 +0,0 @@ -Cloud = false diff --git a/acceptance/apps/import/app-yml-inlined/output.txt b/acceptance/apps/import/app-yml-inlined/output.txt deleted file mode 100644 index 69ca03b4b59..00000000000 --- a/acceptance/apps/import/app-yml-inlined/output.txt +++ /dev/null @@ -1,50 +0,0 @@ - ->>> [CLI] apps import --name myapp --output-dir out -Loading app 'myapp' configuration -Creating bundle configuration -File successfully saved to app.yml -Inlined and removed app.yml -Bundle configuration created at databricks.yml -Binding bundle to existing app -Successfully bound to app 'myapp' -Deploying bundle -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/myapp/default/files... -Updated apps.app -Files: 1 uploaded, 0 deleted -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged -Bundle deployed successfully -Starting app -✓ Getting the status of the app myapp -✓ App is in RUNNING state -✓ App compute is in ACTIVE state -✓ Deployment succeeded -You can access the app at myapp-123.cloud.databricksapps.com -App started successfully - -✔ App 'myapp' imported to [TEST_TMP_DIR]/out - -You can now deploy changes with: databricks bundle deploy - ->>> ls out -databricks.yml - ->>> cat out/databricks.yml -bundle: - name: myapp - -workspace: - host: [DATABRICKS_URL] - -resources: - apps: - app: - config: - command: - - python - - app.py - env: - - name: GREETING - value: hello - name: myapp - description: "" - source_code_path: . diff --git a/acceptance/apps/import/app-yml-inlined/script b/acceptance/apps/import/app-yml-inlined/script deleted file mode 100644 index 00de356d1ea..00000000000 --- a/acceptance/apps/import/app-yml-inlined/script +++ /dev/null @@ -1,14 +0,0 @@ -# Test: apps import of an app whose source contains app.yml. -# Expected: app.yml contents are inlined into databricks.yml as `config` and app.yml is removed. -APP_PATH="/Workspace/Users/$CURRENT_USER_NAME/myapp" -$CLI workspace import-dir src "$APP_PATH" > /dev/null -$CLI apps create myapp > /dev/null -$CLI apps deploy myapp --source-code-path "$APP_PATH" > /dev/null - -trace $CLI apps import --name myapp --output-dir out - -trace ls out - -trace cat out/databricks.yml - -rm -rf out diff --git a/acceptance/apps/import/app-yml-inlined/src/app.yml b/acceptance/apps/import/app-yml-inlined/src/app.yml deleted file mode 100644 index 9b32aa601a6..00000000000 --- a/acceptance/apps/import/app-yml-inlined/src/app.yml +++ /dev/null @@ -1,4 +0,0 @@ -command: ["python", "app.py"] -env: - - name: GREETING - value: hello diff --git a/acceptance/apps/import/app-yml/output.txt b/acceptance/apps/import/app-yml/output.txt index b600b58c013..0baffb149b6 100644 --- a/acceptance/apps/import/app-yml/output.txt +++ b/acceptance/apps/import/app-yml/output.txt @@ -3,13 +3,27 @@ Loading app 'myapp' configuration Creating bundle configuration File successfully saved to app.yml +Inlined and removed app.yml Bundle configuration created at databricks.yml Binding bundle to existing app +Warning: Use 'value_from' instead of 'valueFrom' + at resources.apps.app.config.env[1] + in databricks.yml:18:13 + +The field 'valueFrom' should be 'value_from' (snake_case). The 'valueFrom' field will be ignored. + Successfully bound to app 'myapp' Deploying bundle +Warning: Use 'value_from' instead of 'valueFrom' + at resources.apps.app.config.env[1] + in databricks.yml:18:13 + +The field 'valueFrom' should be 'value_from' (snake_case). The 'valueFrom' field will be ignored. + Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/myapp/default/files... -Files: 2 uploaded, 0 deleted -Resources: 0 created, 0 changed, 0 deleted, 1 unchanged +Updated apps.app +Files: 1 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged Bundle deployed successfully Starting app ✓ Getting the status of the app myapp @@ -24,7 +38,6 @@ App started successfully You can now deploy changes with: databricks bundle deploy >>> ls out -app.yml databricks.yml >>> cat out/databricks.yml @@ -37,23 +50,46 @@ workspace: resources: apps: app: + config: + command: + - python + - app.py + env: + - name: GREETING + value: hello + - name: WAREHOUSE_ID + valueFrom: sql-warehouse + - name: PYTHON_VERSION + value: 3.1 name: myapp description: "" source_code_path: . ->>> cat out/app.yml -command: - - python - - app.py -env: - - name: GREETING - value: hello - - name: WAREHOUSE_ID - valueFrom: sql-warehouse - - name: PYTHON_VERSION - value: 3.10 - === App config the bundle deploys (app.yml, if kept, is uploaded with the source) >>> [CLI] bundle validate -o json -null +Warning: Use 'value_from' instead of 'valueFrom' + at resources.apps.app.config.env[1] + in databricks.yml:18:13 + +The field 'valueFrom' should be 'value_from' (snake_case). The 'valueFrom' field will be ignored. + +{ + "command": [ + "python", + "app.py" + ], + "env": [ + { + "name": "GREETING", + "value": "hello" + }, + { + "name": "WAREHOUSE_ID" + }, + { + "name": "PYTHON_VERSION", + "value": "3.1" + } + ] +} diff --git a/acceptance/apps/import/app-yml/test.toml b/acceptance/apps/import/app-yml/test.toml index 0491f2c2d40..35325bbd652 100644 --- a/acceptance/apps/import/app-yml/test.toml +++ b/acceptance/apps/import/app-yml/test.toml @@ -1,4 +1,4 @@ -Badness = "app.yml is meant to be inlined into databricks.yml as the app's config and removed (inlineAppConfigFile in cmd/apps/import.go), but the check runs before the source files are downloaded, so it never finds app.yml: databricks.yml gets no config and app.yml stays." +Badness = "Inlining loses data: app.yml's valueFrom is copied verbatim but bundle config expects value_from, so WAREHOUSE_ID is deployed with no value (only a warning) while app.yml is deleted; the unquoted 3.10 is re-typed as a number and deployed as 3.1." # Fix path with reverse slashes in the output for Windows. [[Repls]]