GitHub Repo
Dify Community Reports Accidental Deletion of Attachments Shared Across Knowledge Bases
A Dify community report filed on October 20 says deleting a knowledge base dataset may remove attachments still used by another dataset. A proposed fix adds cross-dataset reference checks, but has not been merged; the impact on released versions and the cloud service remains unclear.

Dify’s knowledge base cleanup process has drawn a community report about possible attachment loss. An issue filed on October 20 says that when two datasets in the same workspace reference the same uploaded file, deleting one dataset may also remove the file record and stored object still needed by the other. The report is based on the self-hosted source code at main, commit 638ed4e, and includes reproduction steps using the project’s SQLite test environment. Issue and reproduction steps
The problem lies in attachment lifecycle management. In the reproduction, a UploadFile record is created, then datasets A and B each reference it through SegmentAttachmentBinding. When A is cleaned up, _delete_attachments selects only A’s bindings but directly deletes the corresponding file and underlying object. B’s binding remains, but the actual attachment is gone. This shows that restricting the query to a dataset’s scope does not protect resources shared across datasets. Technical report
This gap could affect the integrity of multimodal RAG inputs. According to Dify’s official documentation, knowledge retrieval results can include image attachments in the files field alongside text chunks, for downstream models with vision capabilities to read. It follows that even if the text and reference relationships remain, deleting the underlying image could leave the material available to the model incomplete. There is currently no public evidence quantifying how many queries have actually been affected. Official retrieval documentation
A proposed fix filed the same day checks whether attachment bindings exist outside the dataset being deleted before removing uploaded files. It also covers cleanup paths for inline images and uploaded source files. The author reports that all 35 related unit tests passed, but the proposal was still open at the time of review and cannot be considered an official fix. The engineering team should next watch for maintainer review, end-to-end deletion tests, and the version that may include the fix. Available evidence also does not indicate that it can restore storage objects already deleted. Fix proposal and verification record