diff --git a/.changes/unreleased/Fixes-20230720-161513.yaml b/.changes/unreleased/Fixes-20230720-161513.yaml new file mode 100644 index 00000000000..9dd9c291cf3 --- /dev/null +++ b/.changes/unreleased/Fixes-20230720-161513.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Ensure `warn_error_options` get serialized in `invocation_args_dict` +time: 2023-07-20T16:15:13.761813-07:00 +custom: + Author: QMalcolm + Issue: "7694" diff --git a/core/dbt/utils.py b/core/dbt/utils.py index c684e13fd17..ffd3f9ae6d4 100644 --- a/core/dbt/utils.py +++ b/core/dbt/utils.py @@ -17,6 +17,7 @@ from contextlib import contextmanager from dbt.events.types import RetryExternalCall, RecordRetryException +from dbt.helper_types import WarnErrorOptions from dbt import flags from enum import Enum from typing_extensions import Protocol @@ -654,6 +655,9 @@ def args_to_dict(args): # this was required for a test case if isinstance(var_args[key], PosixPath) or isinstance(var_args[key], WindowsPath): var_args[key] = str(var_args[key]) + if isinstance(var_args[key], WarnErrorOptions): + var_args[key] = var_args[key].to_dict() + dict_args[key] = var_args[key] return dict_args diff --git a/test/unit/test_context.py b/test/unit/test_context.py index 1c02a650b9a..cb77b56bd0c 100644 --- a/test/unit/test_context.py +++ b/test/unit/test_context.py @@ -423,6 +423,9 @@ def test_invocation_args_to_dict_in_macro_runtime_context( # Comes from unit/utils.py config_from_parts_or_dicts method assert ctx["invocation_args_dict"]["profile_dir"] == "/dev/null" + assert isinstance(ctx["invocation_args_dict"]["warn_error_options"], Dict) + assert ctx["invocation_args_dict"]["warn_error_options"] == {"include": [], "exclude": []} + def test_model_parse_context(config_postgres, manifest_fx, get_adapter, get_include_paths): ctx = providers.generate_parser_model_context(