diff --git a/.nextchanges/bundles/include-locations-warnings.md b/.nextchanges/bundles/include-locations-warnings.md new file mode 100644 index 00000000000..5a756fabb23 --- /dev/null +++ b/.nextchanges/bundles/include-locations-warnings.md @@ -0,0 +1 @@ +* Fix `--include-locations` failing when a resource is missing a required field. ([#7185](https://github.com/databricks/cli/pull/7185)) diff --git a/acceptance/bundle/validate/required_include_locations/databricks.yml b/acceptance/bundle/validate/required_include_locations/databricks.yml new file mode 100644 index 00000000000..bc11407f230 --- /dev/null +++ b/acceptance/bundle/validate/required_include_locations/databricks.yml @@ -0,0 +1,8 @@ +bundle: + name: test-bundle + +resources: + schemas: + # Required field catalog_name is missing. + my_schema: + name: my_schema diff --git a/acceptance/bundle/validate/required_include_locations/out.test.toml b/acceptance/bundle/validate/required_include_locations/out.test.toml new file mode 100644 index 00000000000..2ab253adc73 --- /dev/null +++ b/acceptance/bundle/validate/required_include_locations/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [] diff --git a/acceptance/bundle/validate/required_include_locations/output.txt b/acceptance/bundle/validate/required_include_locations/output.txt new file mode 100644 index 00000000000..745a1ee843b --- /dev/null +++ b/acceptance/bundle/validate/required_include_locations/output.txt @@ -0,0 +1,7 @@ + +>>> [CLI] bundle validate -o json --include-locations +Warning: required field "catalog_name" is not set + at resources.schemas.my_schema + in databricks.yml:8:7 + +{"files":["databricks.yml"],"locations":{"bundle":[[0,2,3]],"resources":[[0,5,3]],"resources.schemas":[[0,7,5]],"resources.schemas.my_schema":[[0,8,7]]},"version":1} diff --git a/acceptance/bundle/validate/required_include_locations/script b/acceptance/bundle/validate/required_include_locations/script new file mode 100644 index 00000000000..8e8aee04ff3 --- /dev/null +++ b/acceptance/bundle/validate/required_include_locations/script @@ -0,0 +1 @@ +trace $CLI bundle validate -o json --include-locations | jq -c .__locations diff --git a/acceptance/bundle/validate/required_include_locations/test.toml b/acceptance/bundle/validate/required_include_locations/test.toml new file mode 100644 index 00000000000..eabbf157836 --- /dev/null +++ b/acceptance/bundle/validate/required_include_locations/test.toml @@ -0,0 +1 @@ +EnvMatrix.DMS = [] diff --git a/libs/logdiag/logdiag.go b/libs/logdiag/logdiag.go index 28ed3b5ba21..406b71a9a3c 100644 --- a/libs/logdiag/logdiag.go +++ b/libs/logdiag/logdiag.go @@ -3,6 +3,7 @@ package logdiag import ( "context" "path/filepath" + "slices" "sync" "github.com/databricks/cli/libs/cmdio" @@ -157,6 +158,8 @@ func LogDiag(ctx context.Context, d diag.Diagnostic) { return } + // Locations may share a backing array with the config tree; copy so the rewrite below doesn't leak into it. + d.Locations = slices.Clone(d.Locations) for i := range d.Locations { // Make location relative to the root if d.Locations[i].File != "" {