This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-29fd8297-0619-4c86-b606-22fbd1a32087 XWIKI-23718 Open

A faulty attachment in a document prevents the sending of attachment events for the other attachments when saving

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-e8ff76f1-3767-434e-bd36-c2fef40d0f0b Vincent Massol created this issue on 14/Nov/25 15:25
 
Summary: A faulty attachment in a document prevents the sending of attachment events for the other attachments when saving
Issue Type: cid:jira-generated-image-avatar-29fd8297-0619-4c86-b606-22fbd1a32087 Bug
Affects Versions: 16.10.0
Assignee: Unassigned
Components: Old Core
Created: 14/Nov/25 15:25
Priority: cid:jira-generated-image-static-major-2e3aaa49-b486-444b-a156-7864356cd749 Major
Reporter: Vincent Massol
Description:

Here's an example of a stack trace I got during a rename operation:

No row with the given identifier exists: \[com.xpn.xwiki.doc.XWikiAttachmentContent#220509689\]: \[\<null entity name>#\<null>\]
class com.xpn.xwiki.XWikiException: Error number 0 in 0: Error number 3231 in 3: Exception while loading attachment Attachment extensions:Extension.Index Application@index-alldocs-docs.png.png
at com.xpn.xwiki.store.XWikiHibernateAttachmentStore.lambda$loadAttachmentContent$0(XWikiHibernateAttachmentStore.java:251)
at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:851)
at com.xpn.xwiki.store.XWikiHibernateBaseStore.executeRead(XWikiHibernateBaseStore.java:927)
at com.xpn.xwiki.store.XWikiHibernateAttachmentStore.loadAttachmentContent(XWikiHibernateAttachmentStore.java:238)
at com.xpn.xwiki.doc.XWikiAttachment.loadAttachmentContent(XWikiAttachment.java:1125)
at com.xpn.xwiki.doc.XWikiAttachment.reloadAttachmentContent(XWikiAttachment.java:949)
at com.xpn.xwiki.doc.XWikiAttachment.getContentInputStream(XWikiAttachment.java:927)
at com.xpn.xwiki.doc.XWikiDocument.retrieveDeletedAttachment(XWikiDocument.java:7440)
at com.xpn.xwiki.doc.XWikiDocument.getAttachmentDiff(XWikiDocument.java:7404)
at com.xpn.xwiki.internal.event.AttachmentEventGeneratorListener.onDocumentUpdatedEvent(AttachmentEventGeneratorListener.java:139)
at com.xpn.xwiki.internal.event.AttachmentEventGeneratorListener.onEvent(AttachmentEventGeneratorListener.java:88)
at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:338)
at org.xwiki.observation.internal.DefaultObservationManager.notify(DefaultObservationManager.java:303)
at com.xpn.xwiki.XWiki.afterSave(XWiki.java:2042)
at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:2130)

The problem was that attachment index-alldocs-docs.png.png was broken in the DB.

However it revealed another issue: if a single attachment is broken, the code at line https://github.com/xwiki/xwiki-platform/blob/456d6149d12d36f5481e70759e7974815591a2c1/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/event/AttachmentEventGeneratorListener.java#L139 will throw an exception and no events will be sent for the other good attachments.

We probably need to bullet proof https://github.com/xwiki/xwiki-platform/blob/b014ad74dca9d338bbbd3e16afccf8448970db04/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java#L7398 so that it doesn't fail when one attachment fails.