For undefined variables, explicitly raise a useful error on pickling #2184
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 #2110
Description
Add a more coherent warning on pickling that indicates what the undefined value's name is and (importantly) what file it's in.
I wasn't able to fully remove the defining-Undefined-in-a-closure stuff because without it, we can't give a message indicating where we found the Undefined.
This is the new behavior:
I would have very much liked to remove the special undefined override, but because of how jinja handles undefined values, it's actually very difficult! You can't make it just raise on undefined, because constants like
1
show up as undefined (I don't understand why or how, but I didn't spend a lot of time on that because what are you going to do, change jinja?). Jinja really only has the capability of erroring out on explicit uses of undefined:missing.x
-> can be an error (__getattr__(self)
-> error)missing['x']
-> can be an error (__getitem__(self)
-> error)missing
* x -> can be an error (__mul__(self)
-> error)Cases like
foo(missing)
wherefoo
doesn't call any of the forbidden magic methods apparently can't be an error without also breaking the use of bare integers.Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.