Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/8166.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix target overrides of `mode`, `cluster_id` and `git` failing with `expected a map to index ..., found nil` when the top-level `bundle` key is empty. ([#8166](https://github.com/databricks/cli/pull/8166))
21 changes: 12 additions & 9 deletions acceptance/bundle/override/null-bundle-key/output.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@

>>> errcode [CLI] bundle validate -o json -t with_mode
Error: failed to perform target override for target=with_mode: expected a map to index "bundle.mode", found nil

Warning: required field "name" is not set
at bundle
in databricks.yml:3:8

Exit code: 1
json.bundle.mode = "development";

>>> errcode [CLI] bundle validate -o json -t with_cluster_id
Error: failed to perform target override for target=with_cluster_id: expected a map to index "bundle.cluster_id", found nil

Warning: required field "name" is not set
at bundle
in databricks.yml:3:8

Exit code: 1
json.bundle.cluster_id = "0123-456789-abcdef";

>>> errcode [CLI] bundle validate -o json -t with_git
Error: failed to perform target override for target=with_git: expected a map to index "bundle.git", found nil

Warning: required field "name" is not set
at bundle
in databricks.yml:3:8

Exit code: 1
json.bundle.git.branch = "main";

>>> errcode [CLI] bundle validate -o json -t without_overrides
Warning: required field "name" is not set
Expand Down
1 change: 0 additions & 1 deletion acceptance/bundle/override/null-bundle-key/test.toml

This file was deleted.

7 changes: 4 additions & 3 deletions bundle/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ func (r *Root) MergeTargetOverrides(name string) error {
}
}

// Below, we're setting fields on the bundle key, so make sure it exists.
if root.Get("bundle").Kind() == dyn.KindInvalid {
root, err = dyn.Set(root, "bundle", dyn.V(map[string]dyn.Value{}))
// Below, we're setting fields on the bundle key, so make sure it is a map.
// It is null when the key is present but empty, e.g. all its fields are commented out.
if b := root.Get("bundle"); b.Kind() == dyn.KindInvalid || b.Kind() == dyn.KindNil {
root, err = dyn.Set(root, "bundle", dyn.NewValue(map[string]dyn.Value{}, b.Locations()))
if err != nil {
return err
}
Expand Down
Loading