-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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/more helpful invalid refs (#1080) #1085
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,17 +194,37 @@ class ParserMacroCapture(jinja2.Undefined): | |
def __init__(self, hint=None, obj=None, name=None, | ||
exc=None): | ||
super(jinja2.Undefined, self).__init__() | ||
|
||
self.node = node | ||
self.name = name | ||
self.package_name = node.get('package_name') | ||
|
||
def __getattr__(self, name): | ||
|
||
# jinja uses these for safety, so we have to override them. | ||
# see https://github.com/pallets/jinja/blob/master/jinja2/sandbox.py#L332-L339 # noqa | ||
if name in ['unsafe_callable', 'alters_data']: | ||
return False | ||
self.unsafe_callable = False | ||
self.alters_data = False | ||
|
||
def __deepcopy__(self, memo): | ||
path = os.path.join(self.node.get('root_path'), | ||
self.node.get('original_file_path')) | ||
|
||
logger.debug( | ||
'A ParserMacroCapture has been deecopy()d, invalid reference ' | ||
'to "{}" in node {}.{} (source path: {})' | ||
.format(self.name, self.node.get('package_name'), | ||
self.node.get('name'), | ||
path)) | ||
|
||
dbt.exceptions.raise_compiler_error( | ||
'dbt has detected at least one invalid reference in {}.{}. ' | ||
'Check logs for more information' | ||
.format(self.node.get('package_name'), self.node.get('name')) | ||
) | ||
|
||
def __getattr__(self, name): | ||
if name == 'name' or name.startswith('__') and name.endswith('__'): | ||
raise AttributeError( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would we raise this error for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because
Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. roger! |
||
"'{}' object has no attribute '{}'" | ||
.format(type(self).__name__, name) | ||
) | ||
|
||
self.package_name = self.name | ||
self.name = name | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put some parens in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did one better and just made it a function