Skip to content
This documentation is currently in preview, therefore subject to change.

Debug Template Validation Errors

Template errors can prevent document generation or produce unexpected output. This guide helps you identify and resolve common template validation errors.


Enabling Error Display

Enable “Inline template syntax errors” in the Build a Doc action:

  • Errors appear in the output document instead of failing the action
  • Helps identify exactly where errors occur
  • Useful during template development

Error Messages

When inline errors are disabled, errors are returned in the action failure response.


Common Syntax Errors

Missing Closing Brackets

Error: Unexpected end of tag

Cause: Tag not properly closed

Wrong:

<<[CustomerName>

Correct:

<<[CustomerName]>>

Unclosed Loops

Error: Unclosed foreach block

Cause: Missing <</foreach>> tag

Wrong:

<<foreach [item in Items]>>
<<[item.Name]>>

Correct:

<<foreach [item in Items]>>
<<[item.Name]>>
<</foreach>>

Unclosed Conditionals

Error: Unclosed if block

Cause: Missing <</if>> tag

Wrong:

<<if [ShowDiscount]>>
Discount applied

Correct:

<<if [ShowDiscount]>>
Discount applied
<</if>>

Data Binding Errors

Invalid Property Path

Error: Invalid path: 'Custmer.Name'

Cause: Typo in property name or path doesn’t exist

Fix: Verify the path matches your JSON structure exactly (case-sensitive)

Null Reference

Error: Null reference at 'Customer.Address.City'

Cause: Parent object is null

Fix: Ensure data is populated, and add null checks or ensure data is populated:

<<if [Customer.Address]>><<[Customer.Address.City]>><</if>>

Type Mismatch

Error: Cannot convert 'string' to 'number'

Cause: Attempting numeric operations on string values

Fix: Ensure data types match expected operations


Loop Errors

Invalid Iterator

Error: Invalid iterator expression

Cause: Malformed foreach syntax

Wrong:

<<foreach [Items]>>

Correct:

<<foreach [item in Items]>>

Array Not Found

Error: 'Items' is not an array

Cause: Property is not an array or doesn’t exist

Fix: Verify the property exists and is an array in your data source


Debugging Techniques

Step 1: Isolate the Problem

  1. Remove complex sections temporarily
  2. Test with minimal template
  3. Add sections back gradually to find the issue

Step 2: Validate JSON Data

  1. Use a JSON validator tool
  2. Ensure structure matches template expectations (see Structure JSON Data)
  3. Check for special characters that might need escaping

Step 3: Check Property Paths

  1. List all placeholders in your template
  2. Verify each path exists in your JSON
  3. Check capitalisation matches exactly

Step 4: Test in Add-in

  1. Use the Word Add-in preview feature
  2. Errors display immediately
  3. Faster iteration than full Power Automate testing

Error Reference Table

ErrorCauseSolution
Unexpected end of tagMissing >>Close all tags with >>
Unclosed foreach blockMissing <</foreach>>Add closing foreach tag
Unclosed if blockMissing <</if>>Add closing if tag
Invalid pathProperty doesn’t existCheck spelling and structure
Null referenceParent object is nullAdd null checks
Type mismatchWrong data typeVerify data types
Invalid expressionSyntax error in expressionCheck expression syntax

Prevention Tips

  1. Use consistent naming - Follow a naming convention for properties
  2. Validate data first - Check data structure before template processing
  3. Test incrementally - Don’t wait until the end to test
  4. Keep templates simple - Break complex logic into data preparation
  5. Use version control - Track template changes