Skip to content
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

[Backport 1.8.latest] Fix setting silence of warn_error_options via dbt_project.yaml flags #10361

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240624-171729.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix setting `silence` of `warn_error_options` via `dbt_project.yaml` flags
time: 2024-06-24T17:17:29.464865-07:00
custom:
Author: QMalcolm
Issue: "10160"
1 change: 1 addition & 0 deletions core/dbt/cli/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def convert_config(config_name, config_value):
ret = WarnErrorOptions(
include=config_value.get("include", []),
exclude=config_value.get("exclude", []),
silence=config_value.get("silence", []),
valid_error_names=ALL_EVENT_NAMES,
)
return ret
Expand Down
12 changes: 5 additions & 7 deletions tests/functional/configs/test_warn_error_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def test_can_silence(self, project, catcher: EventCatcher, runner: dbtRunner) ->
assert_deprecation_warning(result, catcher)

catcher.flush()
runner.invoke(
["run", "--warn-error-options", "{'include': 'all', 'silence': ['DeprecatedModel']}"]
)
result = runner.invoke(["run", "--warn-error-options", "{'silence': ['DeprecatedModel']}"])
assert result.success
assert len(catcher.caught_events) == 0

def test_can_raise_warning_to_error(
Expand Down Expand Up @@ -130,13 +129,12 @@ def test_can_silence(
result = runner.invoke(["run"])
assert_deprecation_warning(result, catcher)

silence_options = {
"flags": {"warn_error_options": {"include": "all", "silence": ["DeprecatedModel"]}}
}
silence_options = {"flags": {"warn_error_options": {"silence": ["DeprecatedModel"]}}}
update_config_file(silence_options, project_root, "dbt_project.yml")

catcher.flush()
runner.invoke(["run"])
result = runner.invoke(["run"])
assert result.success
assert len(catcher.caught_events) == 0

def test_can_raise_warning_to_error(
Expand Down
Loading