Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-66518

Reconcile Unknown Attachments plugin is incompatible with Confiforms macro

      Issue Summary

      https://jira.atlassian.com/browse/CONFSERVER-25507?focusedCommentId=2802070&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2802070

      https://jira.atlassian.com/browse/CONFSERVER-63615?focusedCommentId=2823911&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2823911

       

      Steps to Reproduce

      1. Install both plugins
      2. View a page with a confiforms macro

      Expected Results

      macro renders

      Actual Results

      An error is rendered

      Workaround

      Uninstall reconcile unknown attachments plugin

            [CONFSERVER-66518] Reconcile Unknown Attachments plugin is incompatible with Confiforms macro

            A fix for this issue is available in Confluence Server and Data Center 8.0.3.
            Upgrade now or check out the Release Notes to see what other issues are resolved.

            odykovy (Inactive) added a comment - A fix for this issue is available in Confluence Server and Data Center 8.0.3. Upgrade now or check out the Release Notes to see what other issues are resolved.
            odykovy (Inactive) made changes -
            Resolution New: Fixed [ 1 ]
            Status Original: Waiting for Release [ 12075 ] New: Closed [ 6 ]
            Alex Blekhman (Inactive) made changes -
            Status Original: Awaiting Merge [ 10064 ] New: Waiting for Release [ 12075 ]
            Alex Blekhman (Inactive) made changes -
            Status Original: In Review [ 10051 ] New: Awaiting Merge [ 10064 ]
            Alex Blekhman (Inactive) made changes -
            Fix Version/s Original: No-Version [ 66670 ]
            Fix Version/s New: 8.0.3 [ 104294 ]
            Status Original: In Progress [ 3 ] New: In Review [ 10051 ]
            Alex Blekhman (Inactive) made changes -
            Remote Link New: This issue links to "Confluence Bundled Plugins 80 › Unknown Attachments Reconciliation Plugin (Adoptium Temurin 17) › issue-80-CONFSERVER-66518-plugin-regression (server-syd-bamboo)" [ 723394 ]
            Alex Blekhman (Inactive) made changes -
            Remote Link New: This issue links to "Confluence Bundled Plugins 80 › Unknown Attachments Reconciliation Plugin › issue-80-CONFSERVER-66518-plugin-regression (server-syd-bamboo)" [ 723486 ]

            Hi Alex

            This is extremely helpful, thank you

            We will also make sure we dont convert to storage format if that really is a storage format. I think that was done to make sure the (macro) preview works, as this is when the contents that is given is not in storage format

            You have unblocked a significant amount of (our and yours) customers to migrate to Confluence 8

            Thanks again
            Alex

            Alex Medved {ConfiForms} added a comment - Hi Alex This is extremely helpful, thank you We will also make sure we dont convert to storage format if that really is a storage format. I think that was done to make sure the (macro) preview works, as this is when the contents that is given is not in storage format You have unblocked a significant amount of (our and yours) customers to migrate to Confluence 8 Thanks again Alex

            6dfd011db329, here is the status update of the issue.

            Root cause:
            The ConfiForm macro tries to convert its own XHTML fragment to storage format even though it is already in storage format.

            Details:

            1. Confluence renders a page for view.
            2. Confluence calls com.atlassian.confluence.macro.Macro#execute for each macro on the page.
            3. ConfiForm macro implements this method and somewhere inside implementation calls com.atlassian.confluence.content.render.xhtml.FormatConverter#convertToStorageFormat with incorrect first argument, which is already in storage format. This is where the bug happens.
            4. The confluence-unknown-attachments-reconciliation-plugin installs format transformers: storageToView, storageToEditor, editorToStorage. (The plugin handles representation of unknown attachments in various formats.)
            5. The plugin tries to use editorToStorage transformer on input in storage format. The transformer's XML reader fails to parse the input and throws an exception. Older version of XML parser used to throw com.ctc.wstx.exc.WstxLazyException; new version throws com.ctc.wstx.exc.WstxParsingException.

            In the past we introduced a patch inside confluence-unknown-attachments-reconciliation-plugin by converting WstxLazyException to com.atlassian.confluence.content.render.xhtml.XhtmlException. It seems that ConfiForm macro can handle XhtmlException and somehow recover from it.

            After upgrading XML parsing library in Confluence 8.0, the patch does not work since the exception type changed.

            Solution:

            • I'm going to harden the confluence-unknown-attachments-reconciliation-plugin: when its transformers fail parsing given XHTML input, then they will throw XhtmlException only.
            • At the same time you should fix the ConfiForms macro and stop calling FormatConverter#convertToStorageFormat with an input that is already in storage format.

            I attached a thread dump of the process where you can see the call stack. The thread name is "http-nio-1990-exec-6@54925".
            For your convenience I'm inserting relevant part of the call stack in this comment, as well.

            Stack trace
            "http-nio-1990-exec-6@54925" daemon prio=5 tid=0x15f nid=NA runnable
              java.lang.Thread.State: RUNNABLE
            	  at com.atlassian.confluence.plugins.attachment.reconciliation.marshalling.UnknownAttachmentTransformerBase.transform(UnknownAttachmentTransformerBase.java:61)
            	  at com.atlassian.confluence.plugins.attachment.reconciliation.marshalling.UnknownAttachmentTransformerEditorToStorage.transform(UnknownAttachmentTransformerEditorToStorage.java:30)
            	  at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:33)
            	  at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:39)
            	  at com.atlassian.confluence.content.render.xhtml.editor.DefaultEditorConverter.convert(DefaultEditorConverter.java:37)
            	  at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.convertToStorageFormat(DefaultFormatConverter.java:123)
            	  [...]
            	  at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
            	  at com.sun.proxy.$Proxy565.convertToStorageFormat(Unknown Source:-1)
            	  [...]
            	  at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:130)
            	  at com.sun.proxy.$Proxy565.convertToStorageFormat(Unknown Source:-1)
            	  at com.vertuna.confluence.plugins.confiforms.action.BaseAction.tryToGetBody(BaseAction.java:963)
            	  at com.vertuna.confluence.plugins.confiforms.action.BaseAction.getConfiFormsPage(BaseAction.java:827)
            	  at com.vertuna.confluence.plugins.confiforms.AbstractConfiFormMacro.getConfiFormsPage(AbstractConfiFormMacro.java:197)
            	  at com.vertuna.confluence.plugins.confiforms.ConfiFormMacro.executeToStream(ConfiFormMacro.java:65)
            	  [...]
            	  at com.atlassian.confluence.pages.actions.ViewPageAction.execute(ViewPageAction.java:177)
            	  [...]
            

            Thread dump: threads_report.txt

            Alex Blekhman (Inactive) added a comment - 6dfd011db329 , here is the status update of the issue. Root cause: The ConfiForm macro tries to convert its own XHTML fragment to storage format even though it is already in storage format. Details: Confluence renders a page for view. Confluence calls com.atlassian.confluence.macro.Macro#execute for each macro on the page. ConfiForm macro implements this method and somewhere inside implementation calls com.atlassian.confluence.content.render.xhtml.FormatConverter#convertToStorageFormat with incorrect first argument, which is already in storage format. This is where the bug happens. The confluence-unknown-attachments-reconciliation-plugin installs format transformers: storageToView , storageToEditor , editorToStorage . (The plugin handles representation of unknown attachments in various formats.) The plugin tries to use editorToStorage transformer on input in storage format. The transformer's XML reader fails to parse the input and throws an exception. Older version of XML parser used to throw com.ctc.wstx.exc.WstxLazyException ; new version throws com.ctc.wstx.exc.WstxParsingException . In the past we introduced a patch inside confluence-unknown-attachments-reconciliation-plugin by converting WstxLazyException to com.atlassian.confluence.content.render.xhtml.XhtmlException . It seems that ConfiForm macro can handle XhtmlException and somehow recover from it. After upgrading XML parsing library in Confluence 8.0, the patch does not work since the exception type changed. Solution: I'm going to harden the confluence-unknown-attachments-reconciliation-plugin : when its transformers fail parsing given XHTML input, then they will throw XhtmlException only. At the same time you should fix the ConfiForms macro and stop calling FormatConverter#convertToStorageFormat with an input that is already in storage format. I attached a thread dump of the process where you can see the call stack. The thread name is "http-nio-1990-exec-6@54925". For your convenience I'm inserting relevant part of the call stack in this comment, as well. Stack trace "http-nio-1990-exec-6@54925" daemon prio=5 tid=0x15f nid=NA runnable java.lang. Thread .State: RUNNABLE at com.atlassian.confluence.plugins.attachment.reconciliation.marshalling.UnknownAttachmentTransformerBase.transform(UnknownAttachmentTransformerBase.java:61) at com.atlassian.confluence.plugins.attachment.reconciliation.marshalling.UnknownAttachmentTransformerEditorToStorage.transform(UnknownAttachmentTransformerEditorToStorage.java:30) at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:33) at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:39) at com.atlassian.confluence.content.render.xhtml.editor.DefaultEditorConverter.convert(DefaultEditorConverter.java:37) at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.convertToStorageFormat(DefaultFormatConverter.java:123) [...] at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) at com.sun.proxy.$Proxy565.convertToStorageFormat(Unknown Source:-1) [...] at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:130) at com.sun.proxy.$Proxy565.convertToStorageFormat(Unknown Source:-1) at com.vertuna.confluence.plugins.confiforms.action.BaseAction.tryToGetBody(BaseAction.java:963) at com.vertuna.confluence.plugins.confiforms.action.BaseAction.getConfiFormsPage(BaseAction.java:827) at com.vertuna.confluence.plugins.confiforms.AbstractConfiFormMacro.getConfiFormsPage(AbstractConfiFormMacro.java:197) at com.vertuna.confluence.plugins.confiforms.ConfiFormMacro.executeToStream(ConfiFormMacro.java:65) [...] at com.atlassian.confluence.pages.actions.ViewPageAction.execute(ViewPageAction.java:177) [...] Thread dump: threads_report.txt
            Alex Blekhman (Inactive) made changes -
            Attachment New: threads_report.txt [ 432911 ]

              ablekhman@atlassian.com Alex Blekhman (Inactive)
              oshen@atlassian.com Oliver Shen
              Affected customers:
              11 This affects my team
              Watchers:
              19 Start watching this issue

                Created:
                Updated:
                Resolved: