Skip to content

Commit d13598f

Browse files
Add warning when an invalid value is specified for enum field (#3050)
## Why This PR mirrors the validation we added for required fields not being set: #3044 ## Tests A new acceptance test.
1 parent 02f2844 commit d13598f

File tree

16 files changed

+273
-1
lines changed

16 files changed

+273
-1
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
### Bundles
1414
* Changed logic for resolving `${resources...}` references. Previously this would be done by terraform at deploy time. Now if it references a field that is present in the config, it will be done by DABs during bundle loading ([#3370](https://github.com/databricks/cli/pull/3370))
1515
* Add support for tagging pipelines ([#3086](https://github.com/databricks/cli/pull/3086))
16+
* Add warning for when an invalid value is specified for an enum field ([#3050](https://github.com/databricks/cli/pull/3050))
1617

1718
### API Changes

acceptance/bundle/artifacts/shell/invalid/output.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
>>> [CLI] bundle deploy
3+
Warning: invalid value "invalid" for enum field. Valid values are [bash sh cmd]
4+
at artifacts.my_artifact.executable
5+
in databricks.yml:6:17
6+
37
Building my_artifact...
48
Error: invalid is not supported as an artifact executable, options are: bash, sh or cmd
59

acceptance/bundle/debug/direct/out.stderr.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load_resources)
5353
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(apply_mutators)
5454
10:07:59 Debug: Apply pid=12345 mutator=validate:required
55+
10:07:59 Debug: Apply pid=12345 mutator=validate:enum
5556
10:07:59 Debug: Apply pid=12345 mutator=CheckPermissions
5657
10:07:59 Debug: Apply pid=12345 mutator=TranslatePaths
5758
10:07:59 Debug: Apply pid=12345 mutator=PythonWrapperWarning

acceptance/bundle/debug/direct/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Validation OK!
1414
+>>> [CLI] bundle validate --debug
1515
10:07:59 Info: start pid=12345 version=[DEV_VERSION] args="[CLI], bundle, validate, --debug"
1616
10:07:59 Debug: Found bundle root at [TEST_TMP_DIR] (file [TEST_TMP_DIR]/databricks.yml) pid=12345
17-
@@ -62,8 +64,4 @@
17+
@@ -63,8 +65,4 @@
1818
10:07:59 Debug: Apply pid=12345 mutator=metadata.AnnotateJobs
1919
10:07:59 Debug: Apply pid=12345 mutator=metadata.AnnotatePipelines
2020
-10:07:59 Debug: Apply pid=12345 mutator=terraform.Initialize

acceptance/bundle/debug/tf/out.stderr.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load_resources)
5151
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(apply_mutators)
5252
10:07:59 Debug: Apply pid=12345 mutator=validate:required
53+
10:07:59 Debug: Apply pid=12345 mutator=validate:enum
5354
10:07:59 Debug: Apply pid=12345 mutator=CheckPermissions
5455
10:07:59 Debug: Apply pid=12345 mutator=TranslatePaths
5556
10:07:59 Debug: Apply pid=12345 mutator=PythonWrapperWarning

acceptance/bundle/deploy/jobs/task-source/output.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
>>> [CLI] bundle deploy
3+
Warning: invalid value "github" for enum field. Valid values are [awsCodeCommit azureDevOpsServices bitbucketCloud bitbucketServer gitHub gitHubEnterprise gitLab gitLabEnterpriseEdition]
4+
at resources.jobs.git_job.git_source.git_provider
5+
in databricks.yml:11:23
6+
37
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/task-source/default/files...
48
Deploying resources...
59
Updating deployment state...
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
variables:
2+
my_variable:
3+
type: "complex"
4+
default:
5+
key: "value"
6+
7+
my_variable_invalid:
8+
type: "INVALID_TYPE"
9+
default: "value"
10+
11+
my_variable_type_missing:
12+
default: "value"
13+
14+
my_variable_type_empty:
15+
type: ""
16+
default: "value"
17+
18+
resources:
19+
jobs:
20+
my_job_valid:
21+
tasks:
22+
- task_key: "task1"
23+
# Valid enum value
24+
run_if: "ALL_SUCCESS"
25+
notebook_task:
26+
# Valid enum value
27+
source: "GIT"
28+
notebook_path: "/path/to/notebook"
29+
new_cluster:
30+
# Valid enum values
31+
runtime_engine: "PHOTON"
32+
data_security_mode: "SINGLE_USER"
33+
aws_attributes:
34+
availability: "ON_DEMAND"
35+
ebs_volume_type: "GENERAL_PURPOSE_SSD"
36+
node_type_id: "i3.xlarge"
37+
num_workers: 1
38+
39+
my_job_invalid:
40+
tasks:
41+
- task_key: "task2"
42+
# Invalid enum value - should trigger warning
43+
run_if: "INVALID_CONDITION"
44+
notebook_task:
45+
# Invalid enum value - should trigger warning
46+
source: "INVALID_SOURCE"
47+
notebook_path: "/path/to/notebook"
48+
new_cluster:
49+
# Invalid enum values - should trigger warnings
50+
runtime_engine: "INVALID_ENGINE"
51+
data_security_mode: "INVALID_MODE"
52+
aws_attributes:
53+
availability: "INVALID_AVAILABILITY"
54+
ebs_volume_type: "INVALID_VOLUME_TYPE"
55+
node_type_id: "i3.xlarge"
56+
num_workers: 1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
>>> [CLI] bundle validate
3+
Warning: invalid value "INVALID_AVAILABILITY" for enum field. Valid values are [ON_DEMAND SPOT SPOT_WITH_FALLBACK]
4+
at resources.jobs.my_job_invalid.tasks[0].new_cluster.aws_attributes.availability
5+
in databricks.yml:9:29
6+
7+
Warning: invalid value "INVALID_CONDITION" for enum field. Valid values are [ALL_DONE ALL_FAILED ALL_SUCCESS AT_LEAST_ONE_FAILED AT_LEAST_ONE_SUCCESS NONE_FAILED]
8+
at resources.jobs.my_job_invalid.tasks[0].run_if
9+
in databricks.yml:18:19
10+
11+
Warning: invalid value "INVALID_ENGINE" for enum field. Valid values are [NULL PHOTON STANDARD]
12+
at resources.jobs.my_job_invalid.tasks[0].new_cluster.runtime_engine
13+
in databricks.yml:14:29
14+
15+
Warning: invalid value "INVALID_MODE" for enum field. Valid values are [DATA_SECURITY_MODE_AUTO DATA_SECURITY_MODE_DEDICATED DATA_SECURITY_MODE_STANDARD LEGACY_PASSTHROUGH LEGACY_SINGLE_USER LEGACY_SINGLE_USER_STANDARD LEGACY_TABLE_ACL NONE SINGLE_USER USER_ISOLATION]
16+
at resources.jobs.my_job_invalid.tasks[0].new_cluster.data_security_mode
17+
in databricks.yml:11:33
18+
19+
Warning: invalid value "INVALID_SOURCE" for enum field. Valid values are [GIT WORKSPACE]
20+
at resources.jobs.my_job_invalid.tasks[0].notebook_task.source
21+
in databricks.yml:17:21
22+
23+
Warning: invalid value "INVALID_TYPE" for enum field. Valid values are [complex]
24+
at variables.my_variable_invalid.type
25+
in databricks.yml:42:11
26+
27+
Warning: invalid value "INVALID_VOLUME_TYPE" for enum field. Valid values are [GENERAL_PURPOSE_SSD THROUGHPUT_OPTIMIZED_HDD]
28+
at resources.jobs.my_job_invalid.tasks[0].new_cluster.aws_attributes.ebs_volume_type
29+
in databricks.yml:10:32
30+
31+
Name: test-bundle
32+
Target: default
33+
Workspace:
34+
User: [USERNAME]
35+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
36+
37+
Found 7 warnings
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trace $CLI bundle validate

0 commit comments

Comments
 (0)