From 47d07629c27554d8d5b26dcffafb7ae2da15f7b5 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 12 Jun 2014 11:49:50 -0500 Subject: [PATCH] Don't report incorrect line from jinja exception Jinja reports the wrong line for UndefinedError exceptions, which results in a misleading comment in the state result. This commit removes the line number and context string from the comment, leaving just the error message telling the user which variable is undefined. --- salt/utils/templates.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/salt/utils/templates.py b/salt/utils/templates.py index 31450136ee49..745ccad1d73c 100644 --- a/salt/utils/templates.py +++ b/salt/utils/templates.py @@ -283,14 +283,12 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None): tmplstr) except jinja2.exceptions.UndefinedError as exc: trace = traceback.extract_tb(sys.exc_info()[2]) - line, out = _get_jinja_error(trace, context=unicode_context) - if not line: - tmplstr = '' + out = _get_jinja_error(trace, context=unicode_context)[1] + tmplstr = '' raise SaltRenderError( 'Jinja variable {0}{1}'.format( exc, out), - line, - tmplstr) + buf=tmplstr) except (SaltInvocationError, CommandExecutionError) as exc: trace = traceback.extract_tb(sys.exc_info()[2]) line, out = _get_jinja_error(trace, context=unicode_context)