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

Add a skip and better logging for fatal dbt issues #3603

Merged
merged 4 commits into from Jul 13, 2022

Conversation

alanmcruickshank
Copy link
Member

This is a draft PR to assist with debugging #3587.

We may actually want to consider this a permanent fixture (or a variation of it), to allow dbt projects to a) better understand failing files and b) still lint the rest of the project.

In short, if a dbt_compiler.compile_node() raises any exception - we skip the file and output to the user a stringified version of the dbt error and a reference to the file which caused it for later debugging.

@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #3603 (8581ab8) into main (32687ca) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main     #3603   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          174       174           
  Lines        13244     13244           
=========================================
  Hits         13244     13244           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32687ca...8581ab8. Read the comment docs.

@@ -464,6 +464,12 @@ def make_template(in_str):
node=node,
manifest=self.dbt_manifest,
)
except Exception as err:
# Additional error logging in case we get a fatal dbt error.
raise SQLTemplaterSkipFile( # pragma: no cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the logging look like from this? Curious if we should do one or both of:

Logging where the exception was raised from:

logger.exception("<<MESSAGE>>")

Exception chaining:

raise SQLTemplaterSkipFile(...) from err

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are things I've never used before 🤔 .

On reading - I think we should definitely do the latter. I think it will still result in a skipped file. Doing the former seems like a good idea too. Perhaps with some more information attached.

Great ideas!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit of a Python 🤓, I suppose. 😝

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at what I've done now. Used both 🤓

@alanmcruickshank
Copy link
Member Author

@barrywhart - do you reckon this is a good idea to merge to main, or should I keep this is a debugging branch for now?

On one side, this makes the fatal compilation errors much more manageable for dbt users, and allows some files to be linted (hopefully) - but it also reduces the visibility of those bugs and unless people see the errors, they might no know they're there.

I think I'm leaning toward merge, but could be persuaded otherways.

Views?

@NiallRees - do you have views as a regular dbt user?

@NiallRees
Copy link
Member

NiallRees commented Jul 13, 2022

@barrywhart - do you reckon this is a good idea to merge to main, or should I keep this is a debugging branch for now?

On one side, this makes the fatal compilation errors much more manageable for dbt users, and allows some files to be linted (hopefully) - but it also reduces the visibility of those bugs and unless people see the errors, they might no know they're there.

I think I'm leaning toward merge, but could be persuaded otherways.

Views?

@NiallRees - do you have views as a regular dbt user?

I think it makes sense to merge given that the models were failing anyway, I've not encountered scenarios where the first time I find a model won't compile is from SQLFluff though!

@alanmcruickshank alanmcruickshank marked this pull request as ready for review July 13, 2022 10:15
@alanmcruickshank
Copy link
Member Author

Given what @NiallRees says, I'm going to merge this later today unless anyone else has strong views.

@barrywhart
Copy link
Member

I'm good with merging.

One more possibility -- change the logging output to display in red and/or add a similar print() that displays in red. This makes it less likely to be overlooked.

@alanmcruickshank
Copy link
Member Author

One more possibility -- change the logging output to display in red and/or add a similar print() that displays in red. This makes it less likely to be overlooked.

The text from the templater skip error will already get printed in red 😄 👍

@alanmcruickshank alanmcruickshank merged commit cfded29 into main Jul 13, 2022
@alanmcruickshank alanmcruickshank deleted the ac/dbt_fail_logging branch July 13, 2022 16:29
@noel
Copy link

noel commented Jul 14, 2022

would this resolve the issue where it appears everything is good when dbt compile actually failed?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants