From 68cfa164b82efb7941a587e3266d78855ffcdab6 Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Mon, 24 Jun 2024 16:58:19 -0700 Subject: [PATCH] Fix setting `warn_error_options` via `dbt_project.yaml` flags. Back when I did the work for #10058 (specifically c52d6531) I thought that the `warn_error_options` would automatically be converted from the yaml to the `WarnErrorOptions` object as we were building the `ProjectFlags` object, which holds `warn_error_options`, via `ProjectFlags.from_dict`. And I thought this was validated by the `test_can_silence` test added in c52d6531. However, there were two problems: 1. The definition of `warn_error_options` on `PrjectFlags` is a dict, not a `WarnErrorOptions` object 2. The `test_can_silence` test was broken, and not testing what I thought The quick fix (this commit) is to ensure `silence` is passed to `WarnErrorOptions` instantiation in `dbt.cli.flags.convert_config`. The better fix would be to make the `warn_error_options` of `ProjectFlags` a `WarnErrorOptions` object instead of a dict. However, to do this we first need to update dbt-common's `WarnErrorOptions` definition to default `include` to an empty list. Doing so would allow us to get rid of `convert_config` entirely. --- core/dbt/cli/flags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index a74172484f3..33c2e519819 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -57,6 +57,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