-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[CT-1436] Treat warnings as errors for specific events, based on user configuration #6165
Comments
We need to define how we want this to behave a bit more concretely by allowing include or exclude of specific warn events. Error for all events except the ones listed config:
warn_error: true # all of them
config:
warn_error_override:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath Warn for all events except the one listed config:
warn_error: false # none of them (default)
config:
warn_error_override:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath Question: Should there be separate configs for what to include/exclude from the list based on if |
I like the framing of this as |
As part of this work, we should remove This will involve changing all callsites for Note: This could be a breaking change for community adapters if they use |
It would be great to be able to scope the related configuration so that in a large project you could keep warnings on a project/directory/package while raising errors on others. It would look like:
|
@github-christophe-oudar Thanks for this! After chatting about it with the group, it would be significantly trickier to implement this at the level of the per-project / per-model config, rather than a consistent value for the entire invocation. We're planning to implement the simpler version first, and we should open a new ticket to represent the more granular extension. After further discussion, we're also not thrilled about having two configs for this ( warn_error: true | false | [dict??] | [list??]
# raise errors for any/all types of warnings
warn_error: true
# raise errors for ZERO types of warnings
warn_error: false
# raise errors for any/all types EXCEPT these two
warn_error:
default: true
except:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath
# ONLY raise errors for these two types
warn_error:
default: false
except:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath Thoughts:
# same as 'default: false' + 'except' list
warn_error:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath |
I agree that supporting a global level should cover most use cases. I agree that playing prefix decorator would be pretty confusing inside a YAML file. |
@nathaniel-may comment- Choose what to be warned on and then raise warnings to errors What is the scenario when there is a mix of warnings and errors? Warning for config missing or isn't there. |
My understanding of Nate's proposal:
The appeal of that approach is it's more in keeping with the standard practice of other compilers. The downside is losing some of the flexibility that the more-complex configuration (proposed in this issue) would enable. |
Looking into the code I would say we actually have three types of warnings: deprecations, bad configs and tests + source freshness checks. Both deprecations and configs are already implemented differently since they are both utilizing warn_or_error where tests and source configs are setting the result status based on if the
Looking at other compilers:
GCC actually does something similar where you can
Making a note to not lose it: |
A functionally similar configuration syntax was recently proposed in the dbt should know more about semantic information issue. It turns out that entity definitions also need to provide an overall true/false option, plus some additional include/exclude modifications. Implementing the same configuration syntax for # all warnings are treated as exceptions, same as warn_error: true
warn_error:
include: *
# all warnings are treated as exceptions except NoNodesForSelectionCriteria, UnusedResourceConfigPath
warn_error:
include: *
exclude:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath
# only NoNodesForSelectionCriteria, UnusedResourceConfigPath are treated as errors
warn_error:
include:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath
# invalid - exclude only supported when include is '*'
warn_error:
include:
- ThisEvent
- ThatEvent
exclude:
- NoNodesForSelectionCriteria
- UnusedResourceConfigPath
# invalid
warn_error:
exclude: * |
An observation - it appears yml doesn't support non-quoted special characters such as
This implies that the syntax will be the slightly less clean:
|
c'est comme ça We could support "all" as an alias: warn_error:
include: all # same as "*" |
One thing to check during implementation: The spec looks great as yaml, but dbt Cloud users don't have the ability to write/edit It will need to be possible to pass these data structures in as an env var ( Something like:
|
That could work nicely! One edge case I can think of would be for entity definitions where a column name is actually called 'all' - how would dbt disambiguate between a column named 'all' vs 'include all columns'? I don't think this is an issue for the One way to disambiguate between a column named 'all' vs the directive to include all column names without complex validation would be based on the presence of 'all' as a string vs a list item. For example:
vs
|
my thought exactly |
& the good old fashioned
|
(summary from follow-up convo w @MichelleArk) We can't have one CLI flag that's both a boolean and also a dict. Let's make a new config (+ flag/env var), call it $ DBT_WARN_ERROR_OPTIONS='{"include": "*", "exclude": ["NoNodesForSelectionCriteria", "UnusedResourceConfigPath"}' dbt run
$ dbt --warn-error-options '{"include": "*", "exclude": ["NoNodesForSelectionCriteria", "UnusedResourceConfigPath"}' run Is it a bit ugly? Yes. But it's a single variable, you only need to set it once, you can pop it in a yaml/json validator first, and ultimately, this is a capability intended for fairly advanced users. More important that it's possible on the CLI, than it being ergonomic & delightful. Ultimately, we should also move These two are still identical: $ dbt --warn-error run
$ dbt --warn-error-options '{"include": "all"}' run Theoretically these should also be equivalent: $ dbt --no-warn-error run
$ dbt --warn-error-options '{"include": []}' run Up to us if we eventually (dbt v2) deprecate the existing |
Today,
--warn-error
is a simple on/off switch that turns all warnings into errors. We've gotten multiple requests (#4383, #6080) from users who want finer-grained control for raising errors on specific types of warnings.We should allow users to configure exactly which event classes they want to raise as exceptions instead of warnings. This will be enabled by #6064, which will turn all
warn_or_error
call sites into structured events.Where should this configuration live? It feels like "runtime" config, rather than something that goes in project code. But it might be awkward to pass as a CLI flag or env var. The best places feels like the "user config" which currently lives in
profiles.yml
.The text was updated successfully, but these errors were encountered: