Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-20254

Importing a XAR with an attachment missing a <content> tag produces various issues

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 14.8
    • Attachments
    • None
    • Unknown

    Description

      I tried to import a XAR XML file with an attachment lacking a <content> tag.

      Like this (see also the attached minimal XAR archive to reproduce the issue):

        <attachment>
          <filename>hi</filename>
          <mimetype>text/plain</mimetype>
          <charset>UTF-8</charset>
          <author>XWiki.Admin</author>
          <date>1666270757000</date>
          <version>1.1</version>
          <comment/>
          <filesize>5</filesize>
        </attachment>

      Expected behavior:

      XWiki should handle the missing tag. It should produce an empty attachment, or ignore the attachment, or reject the page, or anything that does not lead to a broken state. A warning could be displayed.

      Actual behavior:

      The attachment appears in the Attachments page, but cannot be downloaded (XWiki says the attachment does not exist. In a CI system that upgrades XAR extensions automatically, the situation cannot be fixed by adding the missing <content> tag back (this does not happen when importing content from a XAR archive)

      Errors can be seen in the logs:

      {{2022-10-20 15:04:02,300 [XWiki Solr index thread] ERROR ttachmentSolrMetadataExtractor - Failed to retrieve the content of attachment [Attachment xwiki:Main.EmptyAttachment@hi]
      com.xpn.xwiki.XWikiException: Error number 3002 in 3: The attachment [Attachment xwiki:Main.EmptyAttachment@hi] (file /home/raph/.xtool/instances/tmp/data/store/file/xwiki/f/4/bd82bfc89241883b9e066ec550727c/attachments/4/9/f68a5c8493ec2c0bf489821c21fc3b/f) could not be found in the filesystem attachment store.
      at org.xwiki.store.legacy.store.internal.FilesystemAttachmentStore.loadAttachmentContent(FilesystemAttachmentStore.java:214)
      at com.xpn.xwiki.doc.XWikiAttachment.loadAttachmentContent(XWikiAttachment.java:1107)
      at com.xpn.xwiki.doc.XWikiAttachment.reloadAttachmentContent(XWikiAttachment.java:931)
      at com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:909)
      at org.xwiki.search.solr.internal.metadata.AbstractSolrMetadataExtractor.getContentAsText(AbstractSolrMetadataExtractor.java:524)
      at org.xwiki.search.solr.internal.metadata.AttachmentSolrMetadataExtractor.setLocaleAndContentFields(AttachmentSolrMetadataExtractor.java:114)
      at org.xwiki.search.solr.internal.metadata.AttachmentSolrMetadataExtractor.setFieldsInternal(AttachmentSolrMetadataExtractor.java:93)
      at org.xwiki.search.solr.internal.metadata.AbstractSolrMetadataExtractor.getSolrDocument(AbstractSolrMetadataExtractor.java:166)
      at org.xwiki.search.solr.internal.DefaultSolrIndexer.getSolrDocument(DefaultSolrIndexer.java:510)
      at org.xwiki.search.solr.internal.DefaultSolrIndexer.processBatch(DefaultSolrIndexer.java:419)
      at org.xwiki.search.solr.internal.DefaultSolrIndexer.run(DefaultSolrIndexer.java:384)
      at java.base/java.lang.Thread.run(Thread.java:833)
      2022-10-20 15:04:02,303 [XWiki Solr index thread] ERROR .DocumentSolrMetadataExtractor - Failed to retrieve the content of attachment [Attachment xwiki:Main.EmptyAttachment@hi]}}

      Attachments

        Activity

          People

            Unassigned Unassigned
            rjakse Raphaël Jakse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: