Skip to content

Enhance WarnErrorOptionsV2 to support per-instance targeting with discriminators - #359

Open
jairus-m wants to merge 3 commits into
mainfrom
jairus/support-discriminator-target-to-warn-error-ops-v2
Open

jairus-m wants to merge 3 commits into
mainfrom
jairus/support-discriminator-target-to-warn-error-ops-v2

Conversation

@jairus-m

@jairus-m jairus-m commented Mar 6, 2026

Copy link
Copy Markdown

resolves #358

Description

Adds per-flag targeting in warn_error_options. This allows users to silence (or error on) specific event instances via <event_name>:<flag_name> without affecting all event change warnings. From the motivating example from the issue this means being able to config:

flags:
  require_all_warnings_handled_by_warn_error: true
  warn_error_options:
    silence:
      # - BehaviorChangeEvent <-- before: silences ALL BehaviorChangeEvents
      - BehaviorChangeEvent:use_managed_iceberg # after: silence specific targets
      - BehaviorChangeEvent:use_materialization_v2 # after: silence specific targets

Notes on implementation:

  • Any event class can support per-instance targeting by overriding/implementing discriminator() (defined on BaseEvent) if more specific targeting is useful for that event class
    • This means WarnErrorOptionsV2 can support any ClassName:discriminator in the future
    • For this PR, BehaviorChangeEvent implements discriminator() to return flag_name
    • No other event classes in this repo really benefit from this, but the generic infra is there
  • Existing errors / silenced logic applies the same hierarchies:
    • discriminated > class > Deprecations > all
    • silence > warn > error
  • BehaviorChangeEvent still targets all behavior-change events (backwards compatible)

Local Testing n Validation

I have a dbt-core sandbox locally that uses the dbt-databricks adapter. I overrode the dbt-commons dependency in the uv virtual environment and pointed it to my local dev branch and ran manual tests:

  1. Control: No silencing, getting both expected warnings (use_managed_iceberg & use_materialization_v2)
Screenshot 2026-03-05 at 8 51 21 PM 2. Test: Silencing `BehaviorChangeEvent:use_managed_iceberg` only Screenshot 2026-03-05 at 8 51 58 PM 3. Test: Silencing both `BehaviorChangeEvent:use_managed_iceberg` and `BehaviorChangeEvent:use_materialization_v2` Screenshot 2026-03-05 at 8 52 41 PM

Both tests show and confirm expected behavior!

Related user reports:

Checklist

NOTE: This PR was created with AI-assistance (Cursor)

@jairus-m
jairus-m requested a review from a team as a code owner March 6, 2026 15:18
@cla-bot cla-bot Bot added the cla:yes label Mar 6, 2026
@codecov-commenter

codecov-commenter commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.57%. Comparing base (f21aa0d) to head (a523985).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
dbt_common/helper_types.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
+ Coverage   72.39%   72.57%   +0.17%     
==========================================
  Files          53       53              
  Lines        3746     3770      +24     
==========================================
+ Hits         2712     2736      +24     
  Misses       1034     1034              
Flag Coverage Δ
unit 72.57% <96.77%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] BehaviorChangeEvent:<flag_name> syntax for per-flag targeting in warn_error_options

2 participants