Issue
During an attachment upload to repository storage, when an error scenario causes a rollback, the attachment file is not removed from the repository. The Case goes into Problemflow (Assigned to Broken process).
Symptoms and Impact
If a database COMMIT fails while writing the attachment from Data-WorkAttach-File to the repository, the same attachment cannot be created in the repository on subsequent attempts, as it already exists in the folder.
After addressing the failure, the following error occurs when reuploading the file:
"The specified file/folder already exists in the target repository. Please specify a different file/folder."
Cases are moved to a problem flow when exceptions occur at runtime, capturing the error details in a problem flow assignment.
Steps to reproduce
- Enable repository storage for attachments.
- Attach a file to a work object.
- Reproduce/Simulate a repository connectivity issue during the file attachment.
- Address the source of the failure.
- Reupload the file using the same name.
- The system moves the case to Broken Processes with the error:
"The specified file/folder already exists in the target repository. Please specify a different file/folder."
Root Cause
A defect in Pega Code/Rules where the associated Link-Attachment and Data-WorkAttach-File objects in the database are rolled back, but the file on the repository is not rolled back.
Solution
This is a complex issue which will be treated as a product enhancement for the upcoming releases.
The logic has been updated to display the file name in the pyFormatAttachmentName activity by prepending the CaseID (if available) and appending a timestamp. The fix will also prevent orphan repository artifacts during normal cancel, rollback, and failed-submit paths by explicitly cleaning up temporary attachment state. There will be a fallback safety-net mechanism for residual orphan cleanup caused by browser abandon, network interruption, node restart, or unexpected transaction failure.
Workaround
An interim workaround is to adjust the file name to allow the upload to proceed.
One way to do this automatically is to append a timestamp to the filename via an override of CallVirusCheck.
For details on the CallVirusCheck extension point see Extension points and supporting Rules for attachments and Performing a virus scan on an attachment.
References
Storing Case attachments using external storage
File upload and download troubleshooting FAQs