Unable to save a page in Confluence due to "The editor content cannot be parsed: Unexpected close tag" error

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

Summary

A page can't be saved after editing or not its content. Depending on the version, a different error in the UI is displayed.

In this example, a page containing Unknown macros can't be saved. In Confluence 5.10.x or earlier versions, the following error will be seen in the page editor when you attempt to save the page:

In recent versions of Confluence (Confluence 6 onward), the error shown in the UI is a generic error message due to the introduction of Collaborative Editing:

Environment

Confluence Server and Datacenter

Diagnosis

This error is usually due to broken HTML content. Identifying what's broken requires a deeper analysis of the problem. It was noticed that the problem may happen when:

  • The current Confluence server doesn't have the third-party app installed or has the app disabled.
  • A page was imported from an instance has had a third-party app that supplied a macro that isn't available in the destination server.
    • An example can be seen in the screenshot below:

                     

  • Content imported from an old version of Confluence.
  • It's possible to edit a page source via an app, if such an app is installed, the editing can break the content.

For Confluence 6.x or later, please check the atlassian-confluence.log file for entries similar to the following:

2020-10-08 16:17:55,953 ERROR [http-nio-26152-exec-4] [rest.api.model.ExceptionConverter] convertServiceException No status code found for exception, converting to internal server error : 
 -- referer: http://localhost:26152/c6152/pages/resumedraft.action?draftId=327701&draftShareId=3c36c82f-f786-42e1-9f44-ef15df719490& | url: /c6152/rest/api/content/327700 | traceId: 29ff1005976571e5 | userName: admin
com.atlassian.confluence.api.service.exceptions.ServiceException: [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </p>; expected </time>.
 at [row,col {unknown-source}]: [1,41253]
	at com.atlassian.confluence.api.impl.service.content.ContentBodyConversionManagerImpl.lambda$computeConversionResources$1(ContentBodyConversionManagerImpl.java:110)
	at com.atlassian.confluence.api.impl.ReadOnlyAndReadWriteTransactionConversionTemplate.executeInReadWrite(ReadOnlyAndReadWriteTransactionConversionTemplate.java:65)
	at com.atlassian.confluence.api.impl.service.content.ContentBodyConversionManagerImpl.computeConversionResources(ContentBodyConversionManagerImpl.java:97)
	at com.atlassian.confluence.api.impl.service.content.ContentBodyConversionManagerImpl.convert(ContentBodyConversionManagerImpl.java:90)
	at com.atlassian.confluence.api.impl.service.content.ContentBodyConversionServiceImpl.convert(ContentBodyConversionServiceImpl.java:65)
	at com.atlassian.confluence.api.impl.service.content.ContentBodyConversionServiceImpl.convert(ContentBodyConversionServiceImpl.java:54)
	at com.atlassian.confluence.content.apisupport.ContentCreator.lambda$setContentBodyOnEntity$0(ContentCreator.java:388)
	at java.util.Optional.map(Optional.java:215)
(...)
Caused by: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </p>; expected </time>.
 at [row,col {unknown-source}]: [1,41713]
	at com.ctc.wstx.sr


Cause

The root cause can change depending on what type of content is broken. In the following example, we're treating a broken macro.

An open tag in the source of the page breaks the macro. Looking into the browser element (right-click >> Inspect Elements) for the "Unknown macro", we see the data-macro-body value as:

%3Cimg+class%3D%22wysiwyg-unknown-macro%22+src%3D%22%2Fconf594%2Fplugins%2Fservlet%2Fconfluence%2Fplaceholder%2Funknown-macro%3Fname%3Dcard%26amp%3Blocale%3Den_GB%26amp%3Bversion%3D2%22+data-macro-name%3D%22card%22+data-macro-id%3D%2235539946-def8-4844-8774-a5e9a5ed08e6%22+data-macro-parameters%3D%22label%3Dtest+1%22+data-macro-schema-version%3D%221%22+data-macro-body%3D%22%253Cp%253Efgsfgfg%253C%252Fp%253E%22%3E%3Cimg+class%3D%22wysiwyg-unknown-macro%22+src%3D%22%2Fconf594%2Fplugins%2Fservlet%2Fconfluence%2Fplaceholder%2Funknown-macro%3Fname%3Dcard%26amp%3Blocale%3Den_GB%26amp%3Bversion%3D2%22+data-macro-name%3D%22card%22+data-macro-id%3D%22c4d0d298-497c-4acd-abcd-acf7faac4168%22+data-macro-parameters%3D%22label%3Dtest+2%22+data-macro-schema-version%3D%221%22+data-macro-body%3D%22%253Cp%253Efgsfgdffdgffgs%253C%252Fp%253E%22%3E%3Cimg+class%3D%22wysiwyg-unknown-macro%22+src%3D%22%2Fconf594%2Fplugins%2Fservlet%2Fconfluence%2Fplaceholder%2Funknown-macro%3Fname%3Dcard%26amp%3Blocale%3Den_GB%26amp%3Bversion%3D2%22+data-macro-name%3D%22card%22+data-macro-id%3D%22606070a5-944c-4c6c-9b3f-dc759396d715%22+data-macro-parameters%3D%22label%3Dtest+3%22+data-macro-schema-version%3D%221%22+data-macro-body%3D%22%253Cp%253Edsgsgfdg%253C%252Fp%253E%22%3E

When we use a URL decoder to convert all the symbol codes, we get this:

<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="35539946-def8-4844-8774-a5e9a5ed08e6" data-macro-parameters="label=test 1" data-macro-schema-version="1" data-macro-body="%3Cp%3Efgsfgfg%3C%2Fp%3E">
<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="c4d0d298-497c-4acd-abcd-acf7faac4168" data-macro-parameters="label=test 2" data-macro-schema-version="1" data-macro-body="%3Cp%3Efgsfgdffdgffgs%3C%2Fp%3E">
<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="606070a5-944c-4c6c-9b3f-dc759396d715" data-macro-parameters="label=test 3" data-macro-schema-version="1" data-macro-body="%3Cp%3Edsgsgfdg%3C%2Fp%3E">

We can see for each <img> tag that is opened, there is no closing tag for it. This is why Confluence throws an error claiming it expected the </img> close tag. If we quickly replace the data-macro-body in the browser console to include a closing tag so that it looks like the code below, the page can save just fine:

<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="35539946-def8-4844-8774-a5e9a5ed08e6" data-macro-parameters="label=test 1" data-macro-schema-version="1" data-macro-body="%3Cp%3Efgsfgfg%3C%2Fp%3E"/>
<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="c4d0d298-497c-4acd-abcd-acf7faac4168" data-macro-parameters="label=test 2" data-macro-schema-version="1" data-macro-body="%3Cp%3Efgsfgdffdgffgs%3C%2Fp%3E"/>
<img class="wysiwyg-unknown-macro" src="/conf594/plugins/servlet/confluence/placeholder/unknown-macro?name=card&locale=en_GB&version=2" data-macro-name="card" data-macro-id="606070a5-944c-4c6c-9b3f-dc759396d715" data-macro-parameters="label=test 3" data-macro-schema-version="1" data-macro-body="%3Cp%3Edsgsgfdg%3C%2Fp%3E"/>

Solution

After identifying the problem content, we have some options on how to resolve it:

  1. Check the error, identify the broken content, and fix it. 
  2. Install the third-party add-on that provides the macro or enable the add-on if you already have it installed.
  3. Remove the "Unknown macro" from the page.

If further assistance is required, please, reach out to Atlassian Support.


Last modified on Nov 30, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.