check if value is actually jinja before adding as template
@@ -19,7 +19,7 @@ import re
import six
import networkx as nx
-from jinja2 import meta
+from jinja2 import meta, exceptions
from oslo_config import cfg
from st2common import log as logging
from st2common.util.config_loader import get_config
@@ -133,9 +133,10 @@ def _process(G, name, value):
) or jinja_utils.is_jinja_expression(complex_value_str)
if is_jinja_expr:
+ try:
+ template_ast = ENV.parse(value)
G.add_node(name, template=value)
- template_ast = ENV.parse(value)
LOG.debug("Template ast: %s", template_ast)
# Dependencies of the node represent jinja variables used in the template
# We're connecting nodes with an edge for every depencency to traverse them
@@ -146,6 +147,10 @@ def _process(G, name, value):
if dependencies:
for dependency in dependencies:
G.add_edge(dependency, name)
+ except exceptions.TemplateSyntaxError as e:
+ G.add_node(name, value=value)
+ # not jinja after all
+ # is_jinga_expression only checks for {{ or {{% for speed
else:
G.add_node(name, value=value)
