I’ve built a Power Automate flow to handle email attachments by saving them to SharePoint and generating a shareable link. Initially, this flow worked without issues, saving attachments with full content to SharePoint. Recently, however, the attachments are saved as corrupted files with only 4 bytes.
- Here’s a detailed breakdown of the issue and troubleshooting steps: Steps and Observations
- Flow Overview:
- Trigger: When a new email arrives (V3).
- Process: Retrieve attachments from email, save them to SharePoint under the folder /OriginalAttachments, and generate a share link.
- File Content Configuration: I use the contentBytes expression for the File Content parameter. (Photo 1)
- Current Issue:
- Recently, the flow began saving attachments as corrupted files with a size of only 4 bytes. When attempting to preview these files on SharePoint, I receive an "Unable to preview file" error. (Photo 2).
- Upon inspection in SharePoint, I noticed that newly saved files are 4 bytes in size, while some previously saved files (from when the flow was functioning properly) retain their original sizes. (Photo 3)
- Troubleshooting Steps Taken:
- Testing Other Flows: I recreated the flow in a premium account, where it worked initially. However, similar issues eventually appeared.
- Checked contentBytes Output:
- In flows where the files are corrupted, contentBytes returns null. (Photo 4).
- In flows where files save correctly, contentBytes returns the expected content as base64. (Photo 5).
- Using Compose to Inspect Outputs:
- The corrupted flow outputs resemble: {...} (Photo 6).
- The correct flow outputs resemble: {base64 content...} (Photo 7).
- Additional Attempts:
- Tried using contentId, attachmentId, and other attachment properties, but files continue saving as 4 bytes.
Questions:
- What could cause contentBytes to return null intermittently in this context, despite the same file and flow configuration?
- Are there specific settings or account limitations that could lead to attachments being saved as 4-byte corrupted files?
- Any recommended fixes to ensure attachments consistently save with their full content in SharePoint?