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

[Bug] flags.warn_error_options.silence should be settable dbt_project.yml #10160

Closed
2 tasks done
jtcohen6 opened this issue May 16, 2024 · 6 comments · Fixed by #10359
Closed
2 tasks done

[Bug] flags.warn_error_options.silence should be settable dbt_project.yml #10160

jtcohen6 opened this issue May 16, 2024 · 6 comments · Fixed by #10359
Assignees
Labels
backport 1.8.latest bug Something isn't working

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented May 16, 2024

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Missing silence here:

def convert_config(config_name, config_value):
"""Convert the values from config and original set_from_args to the correct type."""
ret = config_value
if config_name.lower() == "warn_error_options" and type(config_value) == dict:
ret = WarnErrorOptions(
include=config_value.get("include", []),
exclude=config_value.get("exclude", []),
valid_error_names=ALL_EVENT_NAMES,
)
return ret

Expected Behavior

def convert_config(config_name, config_value):
    """Convert the values from config and original set_from_args to the correct type."""
    ret = config_value
    if config_name.lower() == "warn_error_options" and type(config_value) == dict:
        ret = WarnErrorOptions(
            include=config_value.get("include", []),
            exclude=config_value.get("exclude", []),
            valid_error_names=ALL_EVENT_NAMES,
            silence=config_value.get("silence", []),  # this line is missing above
        )
    return ret

Steps To Reproduce

  1. Create a project with a test in it
# dbt_project.yml
flags:
  warn_error_options:
    silence:
      - TestsConfigDeprecation

tests:  # has been renamed to data_tests
  +enabled: true
  1. dbt parse -> still see the deprecation warning ("The tests config has been renamed to data_tests")
  2. Apply the patch shown above -> dbt parse -> no deprecation warning

Relevant log output

No response

Environment

- Python: 3.10.11
- dbt: 1.8.0

Which database adapter are you using with dbt?

No response

Additional Context

No response

@kokorin
Copy link

kokorin commented May 30, 2024

I want to add some reasoning to this issue.
We checking if we can update to DBT 1.8, and we changed our configs from tests to data_tests.

The problem is that we use several DBT packages and those packages still use tests.
And I believe that DBT package developers will not update from tests to data_tests because they want to support compatibility with previous DBT versions.

May be it even makes sense to allow warning suppression based on package name, rather than suppressing globally for the whole project.

@jtcohen6
Copy link
Contributor Author

@kokorin Appreciate that rationale! We have a separate issue for scoping that deprecation warning more narrowly:

@ChenyuLInx
Copy link
Contributor

https://github.com/dbt-labs/dbt-core/pull/10058/files#diff-9a7ad4b74c0941bce1368c1e8e12f0745bf0152b00f92df206375702b46e3a8eR133-R140
There should be an integration test catching this.
This might be because include is being required now.(something we potentially want to change).

@QMalcolm
Copy link
Contributor

QMalcolm commented Jun 20, 2024

This might be because include is being required now.(something we potentially want to change).

For clarity, specifying include as part of warn_error_options was always required previously. Ever since the initial implementation, include was required when specifying warn_error_options. That made sense in a world where only include/exclude (now error/warn) were the only options. Now that silence exists, that logical requirement kind of breaks down.

@QMalcolm
Copy link
Contributor

QMalcolm commented Jun 21, 2024

About my previous comment, I was wrong. The object requires include be specified, it is not optional. However, in the instantiation in core, we always default it to a list if it is not specified. We can also see that in that instantiation, silence is never passed 🙃 Interestingly, I'm not sure why the related are passing (TestWarnErrorOptionsFromCLI.test_can_silence, TestWarnErrorOptionsFromProject.test_can_silence)

@QMalcolm
Copy link
Contributor

Back when I did the work for #10058 (specifically c52d653) 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 c52d653. 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 (#10359) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.8.latest bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants