question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Var does not exist exception not being caught

See original GitHub issue

Describe the bug

Var does not exist exception not being caught when var being directly referenced in a loop

Steps To Reproduce

For a given example model Example 1

select {{ var('var_that_doesnt_exist') }} as example_field

will raise an exception: Required var 'var_that_doesnt_exist' not found in config:, followed by a list of all the vars supplied to that model.

Example 2

{% for items in var('var_that_doesnt_exist') %}
select {{loop.index}} as example_field_{{loop.index}}
{% endfor %}

will raise an exception: 'NoneType' object is not iterable. This is typically found in YAML config issues and such can be confusing in many cases as it’s not a typical var style exception.

Expected behavior

Examples 1 and 2 to raise the same error (Required var 'var_that_doesnt_exist' not found in config: etc). Example 2 is currently failing during the dbt compile.

I’m happy to fix this up if someone points me in the right direction!

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

installed version: 0.18.1
   latest version: 0.19.1

Your version of dbt is out of date! You can find instructions for upgrading here:
https://docs.getdbt.com/docs/installation

Plugins:
  - snowflake: 0.18.1
  - bigquery: 0.18.1
  - postgres: 0.18.1
  - redshift: 0.18.1

The operating system you’re using: Mac

The output of python --version: Python 3.7.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jpmmcneillcommented, Jun 14, 2021

Hey @jtcohen6 sorry for slow response on this one. I’m not going quiet deliberately, i’ll try to follow up with some context of how I’m seeing users getting this issue (hint - i’m developing packages)

0reactions
github-actions[bot]commented, Dec 12, 2021

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ObjectDoesNotExist not catching a DoesNotExist exception
I'm trying to catch a DoesNotExist exception, and inspecting the code where the exception is thrown is difficult. I can't reach the line ......
Read more >
"Variable does not exist" error in catch block even when the ...
I have written a batch class and using try-catch in its execute method. But on saving the class, getting variable does not exist...
Read more >
After try-catch, a variable '..does not exist in current context'.
After I found it reasonable to make a try-catch to check for correct inout, the compiler can not 'see' a variable.
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
Errors detected during execution are called exceptions and are not unconditionally fatal: you will soon learn how to handle them in Python programs....
Read more >
Throw exception - MATLAB throw - MathWorks
You can access the MException object via a try/catch statement or the ... Throw an exception if an input variable name does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found