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

fix: catch jinja typeerrors during render phase #207

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

devmessias
Copy link

@devmessias devmessias commented Oct 16, 2024

resolves #206

Description

After this, a TypeError in render phase will show the node information

 $ dbt build 
12:26:47  Running with dbt=1.9.0-b2
12:26:47  Registered adapter: duckdb=1.9.0
12:26:47  Encountered an error:
Type Error in model ex2 (models/ex2.sql)
  bad operand type for unary -: 'str'

Checklist

@devmessias devmessias requested a review from a team as a code owner October 16, 2024 12:32
@cla-bot cla-bot bot added the cla:yes label Oct 16, 2024
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 68.42%. Comparing base (1bad6b7) to head (74b437e).

Files with missing lines Patch % Lines
dbt_common/clients/jinja.py 28.57% 5 Missing ⚠️
dbt_common/exceptions/base.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
- Coverage   68.48%   68.42%   -0.07%     
==========================================
  Files          52       52              
  Lines        3389     3401      +12     
==========================================
+ Hits         2321     2327       +6     
- Misses       1068     1074       +6     
Flag Coverage Δ
unit 68.42% <50.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gshank
Copy link
Contributor

gshank commented Oct 17, 2024

Can you add a unit test? It's not always possible, but its preferable. Also you need to run pre-commit run --all-files to get the code checks to pass.

@devmessias
Copy link
Author

Yes, I can! I was just waiting for approval before spending time coding without knowing if the dbt-core team wanted that.

@devmessias
Copy link
Author

Done @gshank

But it seems there are other issues not related with this PR

hatch run lint:all                     (base) 
cmd [1] | - python -m black .
All done! ✨ 🍰 ✨
119 files left unchanged.
cmd [2] | - python -m flake8 .
cmd [3] | - python -m mypy .
tests/unit/test_behavior_flags.py:11: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:12: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:24: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:25: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:30: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:35: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:36: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:41: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:66: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:83: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:84: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:98: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:99: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:157: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:173: error: Missing keys ("source", "description", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:179: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]
tests/unit/test_behavior_flags.py:180: error: Missing keys ("source", "docs_url") for TypedDict "BehaviorFlag"  [typeddict-item]

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

Successfully merging this pull request may close these issues.

[Bug]catch_jinja should capture type errors during the rendering phase and display the node information
3 participants