Skip to content

fix(validation): report unmatched table row conditionals in Word templates - #227

Merged
vaceslav merged 2 commits into
mainfrom
fix/validation-table-row-conditionals
Sep 26, 2026
Merged

vaceslav merged 2 commits into
mainfrom
fix/validation-table-row-conditionals

Conversation

@vaceslav

Copy link
Copy Markdown
Contributor

Found while comparing the OpenDocument and Word validators (#138). DocumentTemplateProcessor.ValidateTemplate said a template was valid when a table row held an unmatched {{#if}} marker, for example {{#if A}} in a row inside a table row loop, or {{#if B}} in the first cell of a table. ProcessTemplate then failed with "Processing failed: Table row conditional start marker '{{#if A}}' has no matching '{{/if}}'." The OpenDocument validator already reports these.

Changes

  • TemplateValidator now runs ConditionalDetector.DetectTableRowConditionals for every table it already checks for table row loops (body, nested tables, headers and footers). It reports the same UnmatchedConditionalStart / InvalidConditionalExpression errors as processing.

Tests

  • ValidationIntegrationTests.ValidateTemplate_UnmatchedTableRowConditional_IsReported_AsProcessingFailsOnIt: two tables. The test checks the exact error messages and types, and that processing fails with the first message.
  • ValidationIntegrationTests.ValidateTemplate_MatchedTableRowConditional_IsValid: a matched row conditional with {{#else}} stays valid.
  • Local runs: Release CI build (0 warnings); TriasDev.Templify.Tests net10/9/8 (2,138 each, LibreOffice round trips included); Tools.Tests 63; Converter.Tests 95; dotnet format --verify-no-changes.

Public API impact

None to the API surface. It is a behavior change as a bug fix: templates that ProcessTemplate rejects because of an unmatched table row conditional now also fail ValidateTemplate. Templates that process successfully are not affected.

…lates

ValidateTemplate accepted a table whose rows hold an unmatched {{#if}} marker while ProcessTemplate failed on it. Found while comparing the ODT and Word validators (#138).
@vaceslav
vaceslav force-pushed the fix/validation-table-row-conditionals branch from 3f4fa5b to d02e9d6 Compare September 26, 2026 16:41
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vaceslav
vaceslav merged commit 9838714 into main Sep 26, 2026
12 checks passed
@vaceslav
vaceslav deleted the fix/validation-table-row-conditionals branch September 26, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants