-
Notifications
You must be signed in to change notification settings - Fork 121
Add warning for when required bundle fields are not set #3044
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
Conversation
| for _, field := range fields { | ||
| vv := v.Get(field) | ||
| if vv.Kind() == dyn.KindInvalid || vv.Kind() == dyn.KindNil { | ||
| diags = diags.Append(diag.Diagnostic{ |
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.
I think it can be converted to use logdiag.LogDiag
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.
It's intentionally collection based because of the sorting needed below. bundle.Apply calls logdiag.LogDiag anyway on these.
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.
If I understood the idea behind logdiag is that eventually we want to replace all mutator to never return anything. Can you instead sort fields to make it determenistic?
| } | ||
|
|
||
| // Sort diagnostics to make them deterministic | ||
| sort.Slice(diags, func(i, j int) bool { |
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.
This purely for tests correct?
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.
Yes
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func benchmarkRequiredMutator(b *testing.B, numJobs int) { |
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.
Should it be a separate PR instead?
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.
I think the current PR is a better destination because the feature is co-versioned with its benchmarks. I don't mind either way though.
| for _, field := range fields { | ||
| vv := v.Get(field) | ||
| if vv.Kind() == dyn.KindInvalid || vv.Kind() == dyn.KindNil { | ||
| diags = diags.Append(diag.Diagnostic{ |
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.
If I understood the idea behind logdiag is that eventually we want to replace all mutator to never return anything. Can you instead sort fields to make it determenistic?
|
@andrewnester I tried it out. Sorting by fields alone does not make the diagnostics deterministic. Loading the bundle configuration itself is non-deterministic w.r.t the order of fields in a map. I think the current approach does not go against the spirit of |
## Release v0.261.0 ### Notable Changes The following CLI commands now have additional required positional arguments: * `alerts-v2 update-alert ID UPDATE_MASK` - Update an alert (v2) * `database update-database-instance NAME UPDATE_MASK` - Update a database instance * `external-lineage create-external-lineage-relationship SOURCE TARGET` - Create an external lineage relationship * `external-lineage update-external-lineage-relationship UPDATE_MASK SOURCE TARGET` - Update an external lineage relationship * `external-metadata update-external-metadata NAME UPDATE_MASK SYSTEM_TYPE ENTITY_TYPE` - Update external metadata * `feature-store update-online-store NAME UPDATE_MASK CAPACITY` - Update an online store * `lakeview create-schedule DASHBOARD_ID CRON_SCHEDULE` - Create a schedule * `lakeview create-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIBER` - Create a subscription * `lakeview update-schedule DASHBOARD_ID SCHEDULE_ID CRON_SCHEDULE` - Update a schedule * `network-connectivity update-private-endpoint-rule NETWORK_CONNECTIVITY_CONFIG_ID PRIVATE_ENDPOINT_RULE_ID UPDATE_MASK` - Update a private endpoint rule ### CLI * Add required query parameters as positional arguments in CLI commands ([#3289](#3289)) ### Bundles * Fixed an issue where `allow_duplicate_names` field on the pipeline definition was ignored by the bundle ([#3274](#3274)) * Add warning for when required bundle fields are not set ([#3044](#3044))
| >>> [CLI] bundle validate -o json -t development | ||
| Warning: required field "quartz_cron_expression" is not set | ||
| at resources.quality_monitors.my_monitor.schedule | ||
| in databricks.yml:17:9 |
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.
This warning should not be there, actually. The whole 'schedule' field is cleared by dev mode and it's okay, not user's problem. However, in the current implementation it is set to null. That null should be treated as absence.
I noticed this because my PR improving null handling actually makes schedule disappear and that removes the warnings: https://github.com/databricks/cli/pull/3230/files#diff-18b1807771a343c3d7e7c543232e7ec53637f4a65b1191ab04becc7706b5fcd5L3
However, we should probably look into fixing null handling in required logic specifically. It may also come from other places.
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.
The whole 'schedule' field is cleared by dev mode and it's okay
That seems like a mistake if this is a field that is required by the API. Does the API succeed even if this field is missing?
## Why This PR mirrors the validation we added for required fields not being set: #3044 ## Tests A new acceptance test.
Changes
This PR adds code to emit warnings when required values are not set in the bundle configuration tree.
Note: We do not show a warning for zero values like "" or
0, only when the value is actually omitted from YAML. Acceptance test atbundle/validate/requiredhas coverage for these cases.Why
Better user experience for the customers.
Tests
A new acceptance test at
bundle/validate/required. The warnings also show up in existing acceptance tests.