fix(validation): report unmatched table row conditionals in Word templates - #227
Merged
Merged
Conversation
…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
force-pushed
the
fix/validation-table-row-conditionals
branch
from
September 26, 2026 16:41
3f4fa5b to
d02e9d6
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while comparing the OpenDocument and Word validators (#138).
DocumentTemplateProcessor.ValidateTemplatesaid 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.ProcessTemplatethen failed with "Processing failed: Table row conditional start marker '{{#if A}}' has no matching '{{/if}}'." The OpenDocument validator already reports these.Changes
TemplateValidatornow runsConditionalDetector.DetectTableRowConditionalsfor every table it already checks for table row loops (body, nested tables, headers and footers). It reports the sameUnmatchedConditionalStart/InvalidConditionalExpressionerrors 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.TriasDev.Templify.Testsnet10/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
ProcessTemplaterejects because of an unmatched table row conditional now also failValidateTemplate. Templates that process successfully are not affected.