"java.lang.IllegalStateException: Cannot remove because there is no parent." When using MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS

Hello
When I use the cleanup option “REMOVE_EMPTY_PARAGRAPHS” and have a mergefield with a new paragraph before the closing braces I get an error

Exception in thread "main" java.lang.IllegalStateException: Cannot remove because there is no parent.
	at com.aspose.words.Node.remove(Unknown Source)
	at com.aspose.words.zzZBF.zzZ(Unknown Source)
	at com.aspose.words.zzZBF.zzSX(Unknown Source)
	at com.aspose.words.zzZBF.zzYXn(Unknown Source)
	at com.aspose.words.zzZBF.zzYXl(Unknown Source)
	at com.aspose.words.zzZBF.zzZ(Unknown Source)
	at com.aspose.words.MailMerge.zzZ(Unknown Source)
	at com.aspose.words.MailMerge.executeWithRegions(Unknown Source)
	at aspose_master.aspose_app.TestApp.main(TestApp.java:15)

I am using aspose-words-21.1. I build a minimal example: example.zip (23.4 KB)

Best,
Peter

@p.binnig

You are performing mail merge with empty data source and TableEnd field is on two paragraphs. Please use the attached template document to avoid this issue. template.zip (22.2 KB)

Yes exactly. I only get this error if I have an TableEnd or TableStart field over two paragraphs.
But this is an very easy to make mistake when creating a template (if the template is big finding this error is not easy).
Is this really the intended behaviour?

@p.binnig

Please create TableEnd or TableStart field in one paragraph instead of multiple paragraphs. Please read following article about working mail merge with regions.
Mail Merge with Regions