Skip to main content

template_syntax_error

HTTP 422 · code: "template_syntax_error" · type: https://docs.formfeed.dev/errors/template-syntax

The template could not be compiled, so nothing was rendered: a tag is not closed or misspelt, a bracket is missing, or the syntax belongs to another template language. The render is recorded as failed and costs nothing.

location says where: line and column in the part that failed. That part can be the template body, the header or the footer; the problem does not say which, so look in all three. For a Word or PowerPoint template, location names the part of the file instead, such as word/document.xml.

Example​

{
"type": "https://docs.formfeed.dev/errors/template-syntax",
"title": "Template syntax error",
"status": 422,
"detail": "unknown block tag: endfo",
"code": "template_syntax_error",
"location": { "line": 41, "column": 3 },
"render_id": "rnd_7da09ab6cd9946b798c187c2a9350852",
"request_id": "req_4b7c1e9a2f3d4c5b8a6e7f9012"
}

render_id is there when a synchronous render failed; an async render keeps the same information in its error (code, message, line, column).

Common causes​

  • An unclosed or misspelt block: {% for %} without {% endfor %}, {% endfo %}, {{#each}} without {{/each}}.
  • Syntax from another language, such as Liquid filters | money: "EUR" in a Jinja2 template (| money("EUR")).
  • Stray {{ or {% in text; escape them or wrap them in {% raw %}…{% endraw %} (Jinja2, Liquid).
  • A settings.pdf.metadata.title, header or footer with template syntax that does not compile: they are compiled like the body.

How to fix it​

  • Go to location.line and location.column. The editor's Problems list shows the same message and names the tab (template, header or footer); formfeed validate reports it in a project before you push.
  • Compare with the syntax table for the template language.

Retry?​

No. The same request gets the same answer. Fix the template (and publish the fixed version, for a stored template), then send the request again with a new Idempotency-Key or without one: a 4xx answer is stored under its key for 24 hours, so the old key returns this problem again. See retrying.