Report node: a Markdown report per document or segment
The report node renders a Markdown report from a Jinja2 template over the fields and verdicts of a
run. There is one report per scope — one per document, or one per segment after a split — each
stored as a run artifact (kind: report, text/markdown) that downloads from
GET /v1/runs/{id}/artifacts/{artifact_id}. No model is called: the output is deterministic byte
for byte, so the node is cacheable (key: the template, the extraction and verdicts of the scope and
the workflow version).
{ "id": "rep", "type": "report", "config": { "template": "# {{ invoice_number }}\n…", "format": "markdown" } }
Template context
| Name | Content |
|---|---|
| each extracted field | {{ invoice_number }}, {{ supplier.name }}, loops over tables ({% for l in line_items %}) |
fields |
the same values as one mapping (also reaches a field called run or segment) |
fields_by_id |
values by field_id |
validations |
the verdicts: rule_id, status, severity, blocking, … |
run |
workflow_id, version_id, graph_hash (nothing that changes between runs of a version) |
document |
what the extraction says about the file (filename, pages) |
segment |
id, label, pages when the scope is a segment, else null |
Extracted values are data: {{ 7*7 }} or {% if %} inside a value is written as text, never
compiled. A variable that does not exist, or a field not found in the document, is written as
<missing: name> (and listed in the node's missing), never an exception: a loop over a missing
table is empty. Names that clash with the reserved ones (fields, fields_by_id, validations,
run, document, segment) stay reachable through fields.
Filters
money(currency, locale):{{ total|money('EUR') }}→1,234.50 EUR;{{ total|money('EUR', 'es') }}→1.234,50 EUR. Localesen(default),es,de,fr; JPY and similar get no decimals, KWD and similar three.date(format):{{ issued|date('%d/%m/%Y') }}formats an ISO date or datetime.
A value that is not a number or an ISO date is written as it is.
Limits and errors
The template runs in a jinja2.sandbox.SandboxedEnvironment; include, extends and import are
not allowed and range is capped at 10 000 items. The template is at most 64 KiB (checked when the
workflow is validated, with its syntax, by the rule report_template_invalid) and the output at most
1 MiB. Typed errors, per scope:
| Code | When |
|---|---|
TEMPLATE_UNSAFE |
the sandbox refused an expression ({{ ''.__class__ }}) |
TEMPLATE_INVALID |
syntax error, a failing expression (division by zero), a loop over a number, a template over 64 KiB |
REPORT_TOO_LARGE |
the output exceeds 1 MiB |
A scope whose template fails ends failed with its typed error and the other scopes go on: the run
ends partially_succeeded (failed if every scope fails).
Example
The template, extraction and verdicts below are committed in tests/fixtures/reports/; the output
is the snapshot the tests compare byte for byte.
# Factura INV-2026-0042
- Proveedor: ACME Suministros SL (B12345678)
- Fecha: 12/03/2026
- Total: 1.234,50 EUR
| Concepto | Cantidad | Importe |
|---|---:|---:|
| Tornillos M4 (caja) | 10 | 250,00 EUR |
| Taladro percutor | 1 | 984,50 EUR |
## Validaciones
- total_matches_lines: pass
- vat_registered: inconclusive
Notas: <missing: notes>