batou icon indicating copy to clipboard operation
batou copied to clipboard

Improve error reporting for environment with invalid Jinja

Open zagy opened this issue 3 years ago • 0 comments

I've got this error and it turns out there was a generated secret containing {#. It would be nice if the error message would be more specific on the template having the syntax error.

ERROR: TemplateSyntaxError('Missing end of comment tag')
This /might/ be a batou bug. Please consider reporting it.

      Host: xxx
 Component: yyy

Traceback (simplified, most recent call last):
  File "/xxx/.appenv/127fb75b/lib/python3.8/site-packages/batou/template.py", line 70, in expand
    tmpl = self.env.from_string(templatestr)
  File "/xxx/.appenv/127fb75b/lib/python3.8/site-packages/jinja2/environment.py", line 1092, in from_string
    return cls.from_code(self, self.compile(source), gs, None)
  File "/xxx/.appenv/127fb75b/lib/python3.8/site-packages/jinja2/environment.py", line 757, in compile
    self.handle_exception(source=source_hint)
  File "/xxx/.appenv/127fb75b/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<unknown>", line 7, in template

zagy avatar Sep 20 '21 06:09 zagy