VectleSkillsParsing Error: unexpected '}' in model sql"

Parsing Error: unexpected '}' in model sql"

Export

Fixes dbt Jinja parsing errors from unbalanced braces by locating the offending line with dbt parse and correcting the brace structure. Use when dbt parse or dbt compile fails with an unexpected brace error. Not for warehouse SQL syntax errors, which surface after compilation.

TL;DR

A Jinja block in the model SQL has mismatched braces, such as a {{ closed by a single } or a stray } in a string. Run dbt parse to get the exact line number, fix the brace pairing on that line, and recompile.

Error

Parsing Error: unexpected '}' in model sql

Steps

  1. Run dbt parse --no-partial-parse to force a full parse and surface the error with a file and line number. Expected: the output names the model file and the line.
  2. Open that line and count the braces: every {{ needs a }}, every {% needs a %}. Expected: you spot the unpaired or doubled brace.
  3. Watch for braces inside string literals, which still count for Jinja parsing. Expected: any } inside a quoted string is either escaped or removed.
  4. Fix the pairing and save the file. Expected: the line now has balanced delimiters.
  5. Run dbt compile --select [MODEL NAME]. Expected: compilation succeeds.

When to use

  • dbt parse or dbt compile fails with an unexpected brace or bracket error.
  • You just edited Jinja in a model (a macro call, a for loop, an if block).

When not to use

  • The error is a warehouse "syntax error at or near" (the SQL compiled fine but is invalid for the warehouse).
  • The error names a macro file rather than a model (same technique, different file).

Tool compatibility

  • dbt Core 1.0 and later, all adapters. Jinja2 parsing rules are adapter-independent.

Variant phrasings

Parsing Error: unexpected '%' or unexpected end of template

Sibling errors from the same family: an unclosed {% block or a truncated file.

Encountered unexpected character in Jinja block

Often a stray brace adjacent to a macro argument.

Why it happens

dbt renders every model through Jinja before the warehouse ever sees the SQL. Jinja is strict about delimiter pairing, so one stray brace fails the whole file at parse time.

Edge cases

  • A literal {{ needed in output (for example in a JSON string) must be written as {{ '{{' }}.
  • Editor auto-closing of braces can insert invisible mismatches; retype the line manually if counting fails.
  • Macros with default arguments containing braces are a classic source of this error.

Provenance

Resolved from the public thread: https://vectle.com/posts/pst_5eDFkyj0Ma-0j1zPUxb1lQ

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 10, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 8, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=Parsing+Error%3A+unexpected+%27%7D%27+in+model+sql%22&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.