Skip to content

Conversation

@shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Jun 12, 2025

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 at bundle/validate/required has 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.

@shreyas-goenka shreyas-goenka changed the base branch from main to generate-required-v3 June 12, 2025 11:52
@shreyas-goenka shreyas-goenka marked this pull request as ready for review June 12, 2025 12:56
@shreyas-goenka shreyas-goenka marked this pull request as ready for review July 11, 2025 13:59
@shreyas-goenka shreyas-goenka changed the title Validate required bundle fields Warn if required bundle fields are not set Jul 11, 2025
@shreyas-goenka shreyas-goenka changed the title Warn if required bundle fields are not set Add warning for when required bundle fields are not set Jul 11, 2025
for _, field := range fields {
vv := v.Get(field)
if vv.Kind() == dyn.KindInvalid || vv.Kind() == dyn.KindNil {
diags = diags.Append(diag.Diagnostic{
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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{
Copy link
Contributor

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?

@shreyas-goenka
Copy link
Contributor Author

@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 logdiag. The diagnostics are all collected in a single function and are streamed as soon as the mutator exits.

@shreyas-goenka shreyas-goenka added this pull request to the merge queue Jul 18, 2025
Merged via the queue into main with commit b7c67d4 Jul 18, 2025
13 checks passed
@shreyas-goenka shreyas-goenka deleted the validate-on-required branch July 18, 2025 14:53
deco-sdk-tagging bot added a commit that referenced this pull request Jul 23, 2025
## 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
Copy link
Contributor

@denik denik Jul 29, 2025

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.

Copy link
Contributor Author

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?

github-merge-queue bot pushed a commit that referenced this pull request Aug 8, 2025
## Why
This PR mirrors the validation we added for required fields not being
set: #3044

## Tests
A new acceptance test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants