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 project names/filenames/values to rendering errors (#2499) #2501

Merged
merged 1 commit into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## dbt 0.17.0 (Release TBD)

### Fixes
- Added filename, project, and the value that failed to render to the exception raised when rendering fails. ([#2499](https:/fishtown-analytics/dbt/issues/2499), [#2501](https:/fishtown-analytics/dbt/pull/2501))


### Under the hood
- Lock protobufs to the last version that had fully functioning releases on all supported platforms ([#2490](https:/fishtown-analytics/dbt/issues/2490), [#2491](https:/fishtown-analytics/dbt/pull/2491))

Expand Down
14 changes: 10 additions & 4 deletions core/dbt/config/renderer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Dict, Any, Tuple, Optional, Union

from dbt.clients.jinja import get_rendered
from dbt.clients.jinja import get_rendered, catch_jinja

from dbt.exceptions import DbtProjectError
from dbt.exceptions import RecursionException
from dbt.exceptions import (
DbtProjectError, CompilationException, RecursionException
)
from dbt.node_types import NodeType
from dbt.utils import deep_map

Expand Down Expand Up @@ -35,7 +36,12 @@ def render_value(
# if it wasn't read as a string, ignore it
if not isinstance(value, str):
return value
return get_rendered(value, self.context, native=True)
try:
with catch_jinja():
return get_rendered(value, self.context, native=True)
except CompilationException as exc:
msg = f'Could not render {value}: {exc.msg}'
raise CompilationException(msg) from exc

def render_data(
self, data: Dict[str, Any]
Expand Down
9 changes: 8 additions & 1 deletion core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,14 @@ def parse_file(self, block: FileBlock) -> None:
# mark the file as seen, even if there are no macros in it
self.results.get_file(block.file)
if dct:
dct = self.raw_renderer.render_data(dct)
try:
dct = self.raw_renderer.render_data(dct)
except CompilationException as exc:
raise CompilationException(
f'Failed to render {block.path.original_file_path} from '
f'project {self.project.project_name}: {exc}'
) from exc

yaml_block = YamlBlock.from_file_block(block, dct)

self._parse_format_version(yaml_block)
Expand Down