From 099e05b882a0c24aa13ceae82dd5b116b2ff4e3f Mon Sep 17 00:00:00 2001 From: simonfaltum Date: Tue, 9 Jun 2026 22:12:03 +0200 Subject: [PATCH] Skip nil quality monitor entries in ApplyPresets Co-authored-by: Isaac --- .../mutator/resourcemutator/apply_presets.go | 3 ++ .../resourcemutator/apply_presets_test.go | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 bundle/config/mutator/resourcemutator/apply_presets_test.go diff --git a/bundle/config/mutator/resourcemutator/apply_presets.go b/bundle/config/mutator/resourcemutator/apply_presets.go index 663adf4a281..f4bb0bf7d55 100644 --- a/bundle/config/mutator/resourcemutator/apply_presets.go +++ b/bundle/config/mutator/resourcemutator/apply_presets.go @@ -186,6 +186,9 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos // Quality monitors presets: Schedule if t.TriggerPauseStatus == config.Paused { for _, q := range r.QualityMonitors { + if q == nil { + continue + } // Remove all schedules from monitors, since they don't support pausing/unpausing. // Quality monitors might support the "pause" property in the future, so at the // CLI level we do respect that property if it is set to "unpaused." diff --git a/bundle/config/mutator/resourcemutator/apply_presets_test.go b/bundle/config/mutator/resourcemutator/apply_presets_test.go new file mode 100644 index 00000000000..c97db137b26 --- /dev/null +++ b/bundle/config/mutator/resourcemutator/apply_presets_test.go @@ -0,0 +1,40 @@ +package resourcemutator + +import ( + "testing" + + "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/databricks-sdk-go/service/catalog" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestApplyPresetsSkipsNilQualityMonitors(t *testing.T) { + b := &bundle.Bundle{ + Config: config.Root{ + Presets: config.Presets{ + TriggerPauseStatus: config.Paused, + }, + Resources: config.Resources{ + QualityMonitors: map[string]*resources.QualityMonitor{ + // Python-generated configs can contain null resource entries that + // bypass AllResourcesHaveValues, so ApplyPresets must skip them. + "nil_monitor": nil, + "monitor": { + TableName: "monitor", + CreateMonitor: catalog.CreateMonitor{ + OutputSchemaName: "catalog.schema", + Schedule: &catalog.MonitorCronSchedule{}, + }, + }, + }, + }, + }, + } + + diags := bundle.Apply(t.Context(), b, ApplyPresets()) + require.NoError(t, diags.Error()) + assert.Nil(t, b.Config.Resources.QualityMonitors["monitor"].Schedule) +}