Why does this error happen: 
a) This error can happen if you have an extra {  bracket in one of your merge fields on templates so you can check all fields to remove this extra character.
– If you do not find any extra bracket symbols, there is a chance there is some hidden formatting in your template. Try creating a new google doc (do not copy it) and see if document will generate with no issue. If the error is resolved with new template ID, then copy section by section of old template to the new one and there should be no more hidden formatting.

OR

b) Or this error can happen when trying to merge related lists into a table on your template, however the parent object is not the document action’s master object.

In this example, the master object is a “Payment”, and they want to merge a related list of “Installations” from its parent “Project Schedule” object. The example merge field was: {!Payment__c.Project_Schedule__r.r.Installations__r.Installation_Street_Address__c}.

How to resolve: 
This type of relationship is not supported with RS Documents. I would suggest following:

Option 1: If Installation is always linked to one Payment – Create new field on the Installation that will be lookup to the Payment. Populate this field with related Payment. In that case it will be possible to use following relationship: {!Payment__c.r.Installations__r.Installation_Street_Address__c}

Option 2: If Installation is linked to multiple Payments – Create new junction object called ‘Installation Payment’ with two lookups – one to Payment and one to Installation. Use this object to connect Payments and Installations. In that case it will be possible to use following relationship: {!Payment__c.r.Installation_Payments__r.Installation__r.Installation_Street_Address__c}