Describe the problem/error/question
I have a list of object comming from a combine going through a loop so far so good, but the issue is the done branch is run multiple time
The merge data is like so (it contains binary too)
[
{
"ExtractedPdf": [
"fake data",
"fake data",
"fake data",
"fake data",
"fake data"
],
"emailId": "",
"emailSubject": "",
"emailSender": "",
"emailDate": "",
"emailBody": ""
},
... (9 more times)
]
the ‘Loop’ branch from the ‘Loop Over Items’ has ‘10 items’
but the ‘Done’ has ‘126 items’
What is the error message (if any)?
No error
Please share your workflow
Share the output returned by the last node
i cannot share the output, but the ‘Done’ should (i think) run once containing a list of object, but it’s the case for the first run of the ‘Done’ branch, after that it run multiple times.
The first the run of the ‘Done’ branch is correct, it’s the data that i want.
Information on your n8n setup
- n8n version: 1.93.0
- Database (default: SQLite): idk
- n8n EXECUTIONS_PROCESS setting (default: own, main): idk
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker
- Operating system: macos (or docker)
1 Like
@PhYdrogen
Can you add the sample data to your flow? The workflow is only running 1 item.
It’s most likely there are something return more than 1 items in the highlight area
Give you an example
This workflow input 5 items and get 25 items after loop.
Because it split again while in loop.
Okay i think you are right i will dig out, i have to mess things out in this (it’s a mess lol)
Thanks for your answers. I’ve looked into it and I think my issue is in my loop that processes the files. I have 10 items that are going into loop process, at the end of this branch, I have a Merge block in ‘append’ mode. The problem is that it gives me 17 outputs (5 pdf and 12 images), and my branch ‘done’ in the looping is called 2 times for a total of 31 items. So the problem is indeed in this loop but the issue is, i don’t really know how to fix this, in code it would have been easier for me because i’m used to it, but n8n it’s hard because it’s like a new language. Anyway i have posted the pictures.
Thanks again
Yeah the problem might related to combine.
Since I can not see the full picture about how it combined.
Let’s discussed about what is your expected output when merge
17 outputs (5 pdf and 12 images) → is this good for you?
or other output format should be more correct.
If code
node is more familiar with you. Feel free to use it!
Just need to deal with the $input
thing in Code
node is not easy to learn
You can add some console.log
in Code
node and open the devtool to debug. It might help you coding faster.
If you want to learn about the merge
. I might need to know the expected output here.
Thanks for the fast reply, in fact i want to at some point reconstruct the object with the data,
like
{
// unique id
'emailid': 'abcdef'
// coming from the processed loop
'pdf_extracted': ["content1", "content2"],
'img_extracted': [""] // (if any)
// original field
'field1': any,
'field2': any,
}
that’s what you can see on the code after the ‘Done’, i totally forgot to mention it, but because it’s an email, sometimes it has pdf, and sometime it has picture, ( in all the attachments ) and sometime nothing (not on my test data but can happend), or even both it’s hard to follow what is happening, that’s why i was saying it’s easier on code (not the node code).
Because you could
for (const currentEmail of listOfEmails) {
currentEmail.pdf_extracted = [];
currentEmail.img_extracted = [];
for (const attachments of listOfAttachments) {
if (attachments.type == 'pdf') {
currentEmail.pdf_extracted.append(extractPdfData(attachments.rawData)); //something like this
} else {
currentEmail.img_extracted.append(openAi.ImageAnalyse(attachments.rawData)); //something like this
}
}
}