From f1af6be601020ffed2057115e48d490458b144b7 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 14 Oct 2026 15:07:53 +0200 Subject: [PATCH 1/5] WIP overrides root --- bundle/config/mutator/set_variables.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bundle/config/mutator/set_variables.go b/bundle/config/mutator/set_variables.go index 3038b05acaf..7d710147655 100644 --- a/bundle/config/mutator/set_variables.go +++ b/bundle/config/mutator/set_variables.go @@ -16,6 +16,12 @@ import ( const bundleVarPrefix = "BUNDLE_VAR_" +// variableOverridesLocation is the file name in the bundle root that values from the +// variable overrides file are located at. The file is written by tools, not users, so +// relative paths in it resolve against the bundle root and diagnostics name it by this +// label rather than by its path under .databricks. +const variableOverridesLocation = "" + type setVariables struct{} func SetVariables() bundle.Mutator { @@ -107,7 +113,7 @@ func readVariablesFromFile(b *bundle.Bundle) (dyn.Value, diag.Diagnostics) { return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to read variables file: %w", err)) } - val, err := jsonloader.LoadJSON(f, filePath) + val, err := jsonloader.LoadJSON(f, filepath.Join(b.BundleRootPath, variableOverridesLocation)) if err != nil { return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to parse variables file %s: %w", filePath, err)) } From 924b35a10f09e2b906e9bd1c1c289e76d156c6ce Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 14 Oct 2026 15:12:05 +0200 Subject: [PATCH 2/5] Resolve relative paths in variable overrides against the bundle root Values from .databricks/bundle//variable-overrides.json are located at in the bundle root: the file is written by tools, so relative paths in it resolve against the bundle root, and diagnostics name it by that label. JSON parse errors still point at the real file. Co-authored-by: Isaac --- .../validate/variable_overrides_file_complex_path/test.toml | 2 -- .../variable-overrides.json | 1 + bundle/config/mutator/set_variables.go | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/acceptance/bundle/validate/variable_overrides_file_complex_path/test.toml b/acceptance/bundle/validate/variable_overrides_file_complex_path/test.toml index ca5df96f13e..a298217f218 100644 --- a/acceptance/bundle/validate/variable_overrides_file_complex_path/test.toml +++ b/acceptance/bundle/validate/variable_overrides_file_complex_path/test.toml @@ -1,5 +1,3 @@ -Badness = "Relative paths in variable-overrides.json resolve inconsistently: task files are resolved against the bundle root (with an error), libraries relative to the overrides file." - [[Repls]] Old = '\\' New = '/' diff --git a/acceptance/bundle/validate/variable_overrides_file_complex_path/variable-overrides.json b/acceptance/bundle/validate/variable_overrides_file_complex_path/variable-overrides.json index 3a44bf858e0..08f24d63e87 100644 --- a/acceptance/bundle/validate/variable_overrides_file_complex_path/variable-overrides.json +++ b/acceptance/bundle/validate/variable_overrides_file_complex_path/variable-overrides.json @@ -1,6 +1,7 @@ { "task": { "task_key": "main", + "unknown_field": 1, "existing_cluster_id": "0123-456789-abcdefgh", "spark_python_task": { "python_file": "./src/main.py" diff --git a/bundle/config/mutator/set_variables.go b/bundle/config/mutator/set_variables.go index 7d710147655..6ad4b9f231d 100644 --- a/bundle/config/mutator/set_variables.go +++ b/bundle/config/mutator/set_variables.go @@ -115,6 +115,8 @@ func readVariablesFromFile(b *bundle.Bundle) (dyn.Value, diag.Diagnostics) { val, err := jsonloader.LoadJSON(f, filepath.Join(b.BundleRootPath, variableOverridesLocation)) if err != nil { + // Report the parse error at the real file. + _, err = jsonloader.LoadJSON(f, filePath) return dyn.InvalidValue, diag.FromErr(fmt.Errorf("failed to parse variables file %s: %w", filePath, err)) } From 02989b470e255534394eaa01d2a7a0b1eaa195ac Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 14 Oct 2026 15:12:29 +0200 Subject: [PATCH 3/5] Changelog Co-authored-by: Isaac --- .nextchanges/bundles/7049.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/bundles/7049.md diff --git a/.nextchanges/bundles/7049.md b/.nextchanges/bundles/7049.md new file mode 100644 index 00000000000..589820de8c2 --- /dev/null +++ b/.nextchanges/bundles/7049.md @@ -0,0 +1 @@ +* Relative paths in variable values from `.databricks/bundle//variable-overrides.json` now resolve against the bundle root. ([#7049](https://github.com/databricks/cli/pull/7049)) From 02871500373b553f8db2d42051fe30cc0e42c844 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 14 Oct 2026 17:23:34 +0200 Subject: [PATCH 4/5] Document the fake variable overrides location as a limitation Co-authored-by: Isaac --- bundle/config/mutator/set_variables.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundle/config/mutator/set_variables.go b/bundle/config/mutator/set_variables.go index 6ad4b9f231d..ded90a11f16 100644 --- a/bundle/config/mutator/set_variables.go +++ b/bundle/config/mutator/set_variables.go @@ -18,8 +18,10 @@ const bundleVarPrefix = "BUNDLE_VAR_" // variableOverridesLocation is the file name in the bundle root that values from the // variable overrides file are located at. The file is written by tools, not users, so -// relative paths in it resolve against the bundle root and diagnostics name it by this -// label rather than by its path under .databricks. +// relative paths in it must resolve against the bundle root. A location serves both +// diagnostics and path resolution (relative to the directory of its file), so we use a +// fake file at the bundle root. The limitation is that diagnostics name this label +// rather than the real file under .databricks. const variableOverridesLocation = "" type setVariables struct{} From 789a917b5a4f9bc61ad16eaaaf53fad8d298a82b Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Thu, 15 Oct 2026 16:08:14 +0200 Subject: [PATCH 5/5] Update variable_overrides_file_complex_path golden after the fallback removal (#7068) Co-authored-by: Isaac --- .../variable_overrides_file_complex_path/output.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/acceptance/bundle/validate/variable_overrides_file_complex_path/output.txt b/acceptance/bundle/validate/variable_overrides_file_complex_path/output.txt index 91342a421cb..4b703d710b7 100644 --- a/acceptance/bundle/validate/variable_overrides_file_complex_path/output.txt +++ b/acceptance/bundle/validate/variable_overrides_file_complex_path/output.txt @@ -1,19 +1,20 @@ >>> [CLI] bundle validate -o json -Error: file .databricks/bundle/default/src/main.py not found +Warning: unknown field: unknown_field + at resources.jobs.my_job.tasks[0] + in :4:6 - -Exit code: 1 +Warn: unable to get spark version for cluster 0123-456789-abcdefgh, err: Not Found [ { "existing_cluster_id": "0123-456789-abcdefgh", "libraries": [ { - "whl": ".databricks/bundle/default/src/lib.whl" + "whl": "src/lib.whl" } ], "spark_python_task": { - "python_file": ".databricks/bundle/default/src/main.py" + "python_file": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/src/main.py" }, "task_key": "main" }