Option 1: Filter Out the Bad Attachments
Add a condition to check file size or name:
Condition:
length(items('Apply_to_each')?['contentBytes']) greater than 1000
This filters out tiny/empty attachments that are usually the problematic ones.
Option 2: Check File Extension
Add another condition:
Condition:
contains(items('Apply_to_each')?['name'], '.pdf')
(or whatever file type you expect)
Option 3: Add File Size Check
Sometimes those numbered attachments are 0 bytes:
Condition: div(length(base64ToBinary(items('Apply_to_each')?['contentBytes'])), 1024) greater than 5
This only processes files larger than 5KB.
Option 4: Fix at the Source
In your "Get Attachment" action:
Make sure you're using the correct trigger
Check if "Include Inline Attachments" is causing issues (turn it off)
Try using "Get Attachments (V2)" instead of the regular version
My Go-To Debug Method:
Add a "Compose" action inside your attachment loop:
Compose:
{
"name": @{items('Apply_to_each')?['name']},
"size": @{length(items('Apply_to_each')?['contentBytes'])},
"type": @{items('Apply_to_each')?['contentType']}
}
If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
Regards,
Riyaz