Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 215
Suggest "did you mean ...?" for unknown key lookups and variable references#6208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
5cb240b39013a5d02728c2a1187e9c128cb66e7406ca109ce5d08da7a1d22d1e0942a81656b787eadf957d038a4ee32425e6c54eaFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Error messages for failed key lookups and variable references now suggest the closest matching key if one is found. ([#6208](https://github.com/databricks/cli/pull/6208)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| bundle: | ||
| name: reference-typo-double-nested-typo-multiple | ||
| variables: | ||
| cluster: | ||
| type: complex | ||
| default: | ||
| spark_version: "13.2.x" | ||
| clusters: | ||
| type: complex | ||
| default: | ||
| spark_version: "13.2.x" | ||
| resources: | ||
| jobs: | ||
| one: | ||
| # Two typos in a single reference across nesting layers, where the outermost | ||
| # key "clustr" is within distance 2 of both "cluster" and "clusters". The | ||
| # lookup fails at the outermost key, so both are suggested and the inner typo | ||
| # ("spark_versio") is never reached. | ||
| name: ${var.clustr.spark_versio} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| bundle: | ||
| name: reference-typo-double-nested-typo | ||
| variables: | ||
| cluster: | ||
| type: complex | ||
| default: | ||
| spark_version: "13.2.x" | ||
| resources: | ||
| jobs: | ||
| one: | ||
| # Two typos in a single reference across nesting layers: "clustr" (cluster) | ||
| # and "spark_versio" (spark_version). The lookup fails at the outermost key, | ||
| # so only "cluster" is suggested; the inner typo is never reached. | ||
| name: ${var.clustr.spark_versio} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| bundle: | ||
| name: reference-typo-multiple-typos | ||
| variables: | ||
| cluster: | ||
| type: complex | ||
| default: | ||
| spark_version: "13.2.x" | ||
| node_type_id: Standard_DS3_v2 | ||
| resources: | ||
| jobs: | ||
| # Two typos in references to a complex (nested) variable. References are | ||
| # resolved in sorted order of their config path, and resolution stops at the | ||
| # first unresolved one, so only job "a" is reported even though "b" is wrong too. | ||
| a: | ||
| # Deeply nested typo: ${var.cluster.spark_versio} should be spark_version. | ||
| name: ${var.cluster.spark_versio} | ||
| b: | ||
| # Typo at the variable name: ${var.clustr.node_type_id} should be cluster. | ||
| name: ${var.clustr.node_type_id} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| bundle: | ||
| name: reference-typo-multiple | ||
| variables: | ||
| host: | ||
| default: https://example.test | ||
| hosts: | ||
| default: https://example.test | ||
| resources: | ||
| jobs: | ||
| one: | ||
| # "hst" is within edit distance 2 of both "host" and "hosts" | ||
| name: ${var.hst} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| bundle: | ||
| name: reference-typo-non-var-multiple | ||
| resources: | ||
| jobs: | ||
| one: | ||
| # A non-"var" reference. "stot_path" is within edit distance 2 of both | ||
| # workspace.root_path and workspace.state_path | ||
| name: ${workspace.stot_path} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| === Typo of a defined variable: single suggestion | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${var.hst} | ||
| did you mean: | ||
| ${var.host} | ||
| Name: reference-typo | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo/default | ||
| Found 1 error | ||
| === Typo close to two defined variables: multiple suggestions | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${var.hst} | ||
| did you mean one of: | ||
| ${var.host} | ||
| ${var.hosts} | ||
| Name: reference-typo-multiple | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo-multiple/default | ||
| Found 1 error | ||
| === Typo in a non-variable reference (workspace field): multiple suggestions | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${workspace.stot_path} | ||
| did you mean one of: | ||
| ${workspace.root_path} | ||
| ${workspace.state_path} | ||
| Name: reference-typo-non-var-multiple | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo-non-var-multiple/default | ||
| Found 1 error | ||
| === Nested complex variable with multiple typos: only the first is reported | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${var.cluster.spark_versio} | ||
| did you mean: | ||
| ${var.cluster.spark_version} | ||
| Name: reference-typo-multiple-typos | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo-multiple-typos/default | ||
| Found 1 error | ||
| === Two typos in one reference: lookup fails at the outermost key | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${var.clustr.spark_versio} | ||
| did you mean: | ||
| ${var.cluster.spark_versio} | ||
Comment on lines
+71
to
+74
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't great, but not much we can do since we fail fast and traversing the suggestion in search for valid references is probably overkill | ||
| Name: reference-typo-double-nested-typo | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo-double-nested-typo/default | ||
| Found 1 error | ||
| === Two typos in one reference, outermost close to two variables: multiple suggestions | ||
| >>> [CLI] bundle validate | ||
| Error: reference does not exist: ${var.clustr.spark_versio} | ||
| did you mean one of: | ||
| ${var.cluster.spark_versio} | ||
| ${var.clusters.spark_versio} | ||
| Name: reference-typo-double-nested-typo-multiple | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/reference-typo-double-nested-typo-multiple/default | ||
| Found 1 error | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| title "Typo of a defined variable: single suggestion\n" | ||
| withdir single musterr trace $CLI bundle validate | ||
| title "Typo close to two defined variables: multiple suggestions\n" | ||
| withdir multiple musterr trace $CLI bundle validate | ||
| title "Typo in a non-variable reference (workspace field): multiple suggestions\n" | ||
| withdir non-var-multiple musterr trace $CLI bundle validate | ||
| title "Nested complex variable with multiple typos: only the first is reported\n" | ||
| withdir multiple-typos musterr trace $CLI bundle validate | ||
| title "Two typos in one reference: lookup fails at the outermost key\n" | ||
| withdir double-nested-typo musterr trace $CLI bundle validate | ||
| title "Two typos in one reference, outermost close to two variables: multiple suggestions\n" | ||
| withdir double-nested-typo-multiple musterr trace $CLI bundle validate |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| bundle: | ||
| name: reference-typo | ||
| variables: | ||
| host: | ||
| default: https://example.test | ||
| resources: | ||
| jobs: | ||
| one: | ||
| # "hst" is a typo of the "host" variable defined above | ||
| name: ${var.hst} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this is now very clear and actionable!