generated from dbt-labs/dbt-oss-template
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Update fire_event
to handle warn_or_error
logic
#237
Open
QMalcolm
wants to merge
5
commits into
main
Choose a base branch
from
qmalcolm--236-fire-event-handles-warn-or-error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ager` `WARN_ERROR` and `WARN_ERROR_OPTIONS` were introduced _before_ we had our `EventManager` architecture. We never moved them, because we never had a need to. However, we're working to wrap `warn_or_error` functionality into `fire_event`. As such, `EventManager` will need the context of `warn_error` and `warn_errror_options`. As a secondary effect, we're eliminating some globals / module variables, which will make our event architecture a little less complicated.
Now whenever `warn_or_error` is called, it actually just passes it through to `fire_event`. That is, `warn_or_error` will now be deprecated, and shouldn't be used. As `warn_or_error` optionally takes a "node", `fire_event` had to be updated to handle this extra argument.
…rn_or_error` Previously only `warn` events handed directly to `warn_or_error` got the `warn_or_error` treatment. In the prior commit we moved the `warn_or_error` handling logic to `fire_event` which meant _all_ warnings were suddenly being handled by the `warn_or_error` logic. This is undesirable as it would break a lot of dbt-core projects. This commit takes it a step back by only using the `warn_or_error` logic in `fire_event` if `force_warn_or_error_handling=True` is passed to `fire_event` (by default it is `False`). Calls to `warn_or_error` will _automatically_ pass `True` for this parameter.
… logic We want to move to a world where _all_ warnings are handled by the `warn_or_error` logic that now lives in `fire_event`. However we can't by default do that as that would break many dbt-core projects currently. That is, not all warnings in dbt-core are fired with `warn_or_error`. Thus if a project has `--warn-error` set, some set of warnings which weren't previously being handled by `warn_or_error` would now be handled by `warn_or_error` if `fire_event` handled all warnings with `warn_or_error`, which would cause errors that were previously happening. Thus by default _we don't_ handle all warnings in `fire_event` with `warn_or_error`. Instead a warning in `fire_event` will only be handled with `warn_or_error` logic if either 1. `force_warn_or_error_handling` is passed as True OR 2. `require_warn_or_error_handing` is set to True (1) only happens if the event was initially sent via the old `warn_or_error` function (2) will only happen if a corresponding project flag set in dbt-core
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #237 +/- ##
==========================================
+ Coverage 68.89% 68.94% +0.05%
==========================================
Files 52 52
Lines 3433 3439 +6
==========================================
+ Hits 2365 2371 +6
Misses 1068 1068
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #236
Description
In dbt-labs/dbt-core#11116 we have resolved to allow people to opt in to having all warnings be handled by the logic of the warn_or_error function. There are a few ways we could have solved this
warn
level event currently fired withfire_event
to be conditionally either fired withwarn_or_error
orfire_event
based on a behavior flagfire_event
helper which does what is described in (1) for every warn passed into it (an then updated every call to dbt-common'sfire_event
to instead be dbt-core'sfire_event
fire_event
to optionally put everywarn
even through thewarn_or_error
logic depending on a behavior flagThis PR implements option (3), as I believe (3) to be less error-prone than (1) or (2) as both (1) and (2) allow us to accidentally forget to send warnings through the new workflow. However, as I was opening this PR I realized (3) is not perfect. For instance, consider that we introduce a new warning for an already existing feature in core. If a user has opted in via the behavior flag, and is running with
--warn-error
, then this new warning could break their previously working project 🫠Checklist
changie new
to create a changelog entry