Skip to content

Commit 9c0e9ed

Browse files
committed
make use of Validate for better error messages
1 parent 7bc39dc commit 9c0e9ed

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

acceptance/bundle/bundle_tag/url_ref/out.deploy.direct-exp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
2-
Error: cannot resolve ${resources.jobs.foo.url}: url: field "url" not found in resources.Job
2+
Error: schema mismatch for ${resources.jobs.foo.url}: url: field "url" not found in resources.Job
33

44
Error: cannot plan jobs.bar: dependency failed: jobs.foo
55

acceptance/bundle/bundle_tag/url_ref/out.plan.direct-exp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Error: cannot resolve ${resources.jobs.foo.url}: url: field "url" not found in resources.Job
1+
Error: schema mismatch for ${resources.jobs.foo.url}: url: field "url" not found in resources.Job
22

33
Error: cannot plan jobs.bar: dependency failed: jobs.foo
44

acceptance/bundle/resource_deps/non_existent_field/out.deploy.direct-exp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
2-
Error: cannot resolve ${resources.volumes.bar.non_existent}: non_existent: field "non_existent" not found in resources.Volume
2+
Error: schema mismatch for ${resources.volumes.bar.non_existent}: non_existent: field "non_existent" not found in resources.Volume
33

44
Error: cannot plan volumes.foo: dependency failed: volumes.bar
55

acceptance/bundle/resource_deps/non_existent_field/out.plan.direct-exp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Error: cannot resolve ${resources.volumes.bar.non_existent}: non_existent: field "non_existent" not found in resources.Volume
1+
Error: schema mismatch for ${resources.volumes.bar.non_existent}: non_existent: field "non_existent" not found in resources.Volume
22

33
Error: cannot plan volumes.foo: dependency failed: volumes.bar
44

bundle/terranova/plan.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"errors"
77
"fmt"
8+
"reflect"
89
"slices"
910

1011
"github.com/databricks/cli/bundle"
@@ -177,9 +178,14 @@ func CalculatePlanForDeploy(ctx context.Context, b *bundle.Bundle) error {
177178
logdiag.LogError(ctx, fmt.Errorf("cannot parse path %s: %w", fieldPath, err))
178179
return false
179180
}
181+
validationErr := structaccess.Validate(reflect.TypeOf(config), dynPath)
182+
if validationErr != nil {
183+
logdiag.LogError(ctx, fmt.Errorf("schema mismatch for %s: %w", reference, validationErr))
184+
return false
185+
}
180186
value, err := structaccess.Get(config, dynPath)
181187
if err != nil {
182-
logdiag.LogError(ctx, fmt.Errorf("cannot resolve %s: %w", reference, err))
188+
logdiag.LogError(ctx, fmt.Errorf("field not set %s: %w", reference, err))
183189
return false
184190
}
185191
err = resolveFieldReference(ctx, b, path, value)

0 commit comments

Comments
 (0)