Skip to content

Commit 2a3cf48

Browse files
[minor] Improve variable assignment error message (#4177)
This clarifies the error message for unassigned variables, making it more AI-friendly. ## Why The original error could send an AI into a wild goose chase related to advanced overriding techniques whenever the AI would generate a databricks.yml without all variables being assigned. Co-authored-by: Claude <[email protected]>
1 parent 0963848 commit 2a3cf48

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

acceptance/bundle/variables/empty/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cleaned up during bundle destroy.
55
at bundle.name
66
in databricks.yml:7:9
77

8-
Error: no value assigned to required variable a. Assignment can be done using "--var", by setting the BUNDLE_VAR_a environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
8+
Error: no value assigned to required variable a. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_a environment variable, or .databricks/bundle/<target>/variable-overrides.json
99

1010
Name: empty${var.a}
1111
Target: default

acceptance/bundle/variables/env_overrides/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"prod-a env-var-b"
1010

1111
>>> errcode [CLI] bundle validate -t env-missing-a-required-variable-assignment
12-
Error: no value assigned to required variable b. Assignment can be done using "--var", by setting the BUNDLE_VAR_b environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
12+
Error: no value assigned to required variable b. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_b environment variable, or .databricks/bundle/<target>/variable-overrides.json
1313

1414
Name: test bundle
1515
Target: env-missing-a-required-variable-assignment

acceptance/bundle/variables/file-defaults/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Exit code: 1
100100

101101
=== variable is required but it's not provided in the file
102102
>>> errcode [CLI] bundle validate -o json --target without_defaults
103-
Error: no value assigned to required variable cluster. Assignment can be done using "--var", by setting the BUNDLE_VAR_cluster environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
103+
Error: no value assigned to required variable cluster. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_cluster environment variable, or .databricks/bundle/<target>/variable-overrides.json
104104

105105

106106
Exit code: 1

acceptance/bundle/variables/vanilla/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"abc def"
44

55
>>> errcode [CLI] bundle validate
6-
Error: no value assigned to required variable b. Assignment can be done using "--var", by setting the BUNDLE_VAR_b environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
6+
Error: no value assigned to required variable b. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the BUNDLE_VAR_b environment variable, or .databricks/bundle/<target>/variable-overrides.json
77

88
Name: foobar
99
Target: default

bundle/config/mutator/set_variables.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func setVariable(ctx context.Context, v dyn.Value, variable *variable.Variable,
9191
}
9292

9393
// We should have had a value to set for the variable at this point.
94-
return dyn.InvalidValue, fmt.Errorf(`no value assigned to required variable %s. Assignment can be done using "--var", by setting the %s environment variable, or in %s file`, name, bundleVarPrefix+name, getDefaultVariableFilePath("<target>"))
94+
return dyn.InvalidValue, fmt.Errorf(`no value assigned to required variable %s. Variables are usually assigned in databricks.yml, and they can be overridden using "--var", the %s environment variable, or %s`, name, bundleVarPrefix+name, getDefaultVariableFilePath("<target>"))
9595
}
9696

9797
func readVariablesFromFile(b *bundle.Bundle) (dyn.Value, diag.Diagnostics) {

bundle/config/mutator/set_variables_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestSetVariablesErrorsIfAValueCouldNotBeResolved(t *testing.T) {
108108
require.NoError(t, err)
109109

110110
_, err = setVariable(context.Background(), v, &variable, "foo", dyn.NilValue)
111-
assert.ErrorContains(t, err, "no value assigned to required variable foo. Assignment can be done using \"--var\", by setting the BUNDLE_VAR_foo environment variable, or in .databricks/bundle/<target>/variable-overrides.json file")
111+
assert.ErrorContains(t, err, "no value assigned to required variable foo. Variables are usually assigned in databricks.yml, and they can be overridden using \"--var\", the BUNDLE_VAR_foo environment variable, or .databricks/bundle/<target>/variable-overrides.json")
112112
}
113113

114114
func TestSetVariablesMutator(t *testing.T) {

0 commit comments

Comments
 (0)