Unable to save workflow

I have added 7 Rss feed trigger nodes and code node then send email node. I m unable to save the workflow and throws the below error.

Error:
Problem saving workflow
There was a problem activating the workflow: "Reduce of empty array with no initial value

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

N8n version : 1.49.0
Running via Docker
DB: Postgres
OS: Centos8

Hi @Ananth_Rayala ,

This error is likely coming from the code node. Are you using an array.prototype.reduce() method without providing it with an initial value?

Could you maybe share your code?

1 Like

Added the code here @mariana-na

// Retrieve the input data
const inputData = $input.all();
const outputData = [];

// Check if inputData is empty
if (inputData.length === 0) {
    // Return a message indicating no data found
    return [{
        json: {
            message: 'No data found from RSS feeds.'
        }
    }];
}

// Iterate over each item
for (const item of inputData) {
    const dateval = item.json.pubDate;
    const Subval = item.json.title;
    const Descval = item.json.content;
    const link = item.json.link;
    
    // Check if dateval is valid
    if (!dateval) {
        outputData.push({
            json: {
                error: 'Invalid date value',
                Title: Subval,
                Content: Descval,
                URL: link
            }
        });
        continue;
    }

    // Step 1: Parse the GMT date string to a Date object
    const gmtDateStr = dateval;
    const gmtDate = new Date(gmtDateStr);
    
    // Step 2: Convert the GMT date to IST
    // IST is GMT+5:30
    const istOffset = 5.5 * 60; // 5 hours and 30 minutes in minutes
    const istDate = new Date(gmtDate.getTime() + istOffset * 60 * 1000);
    
    // Step 3: Format the IST date to a readable string
    const istDateStr = istDate.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' });
    
    // Prepare the output data
    outputData.push({
        json: {
            ISTDate: istDateStr,
            Title: Subval,
            Content: Descval,
            URL: link
        }
    });
}

// Return the converted dates for all items
return outputData;

N8N is accepting only one trigger node. Unable to save multiple trigger nodes in single flow.

I have multiple RSS trigger nodes, since some trigger nodes might not have any data and some might have data, due to empty RSS trigger nodes I m unable to save the workflow

@Ananth_Rayala
n8n accepts multiple trigger nodes, so that should not be the issue here.
If you have a (trigger) node that is not configured correctly, it will block activating the workflow. So that is probably what is happening here.

If you test your workflow and this test has an error in it because of your code not being executed properly for example this will also result in it not wanting to activate the flow with that error. Simply refreshing the page should fix that. But of course it would be best to fix your error first. :slight_smile:

For Single RSS feed trigger node, this is working perfectly fine. I have added a condition in code to handle empty input coming to code node. Any other suggestion would really help.

whenever I m trying to add a rss url in rss feed trigger node, which has no data I m unable to save the flow, but when I add multiple rss feed trigger node which has data I m able to save the workflow

const inputData = $input.all();
const outputData = [];

// Check if inputData is empty
if (inputData.length === 0) {
    // Return a message indicating no data found
    return [{
        json: {
            message: 'No data found from RSS feeds.'
        }
    }];
}

// Iterate over each item
for (const item of inputData) {
    // Check if item.json exists and has the expected properties
    if (!item.json || !item.json.pubDate || !item.json.title || !item.json.content || !item.json.link) {
        outputData.push({
            json: {
                error: 'Invalid data structure',
                item: item
            }
        });
        continue;
    }
    
    const dateval = item.json.pubDate;
    const Subval = item.json.title;
    const Descval = item.json.content;
    const link = item.json.link;
    
    // Step 1: Parse the GMT date string to a Date object
    const gmtDateStr = dateval;
    const gmtDate = new Date(gmtDateStr);
    
    // Step 2: Convert the GMT date to IST
    // IST is GMT+5:30
    const istOffset = 5.5 * 60; // 5 hours and 30 minutes in minutes
    const istDate = new Date(gmtDate.getTime() + istOffset * 60 * 1000);
    
    // Step 3: Format the IST date to a readable string
    const istDateStr = istDate.toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' });
    
    // Prepare the output data
    outputData.push({
        json: {
            ISTDate: istDateStr,
            Title: Subval,
            Content: Descval,
            URL: link
        }
    });
}

// Return the converted dates for all items
return outputData;

Hi Team,

Any solution for the above request?

Hi!

Were you guys able to figuring this out?

I’ve tried another approach without any Code node (only Edit Fields), it gives me the same result.
The test workflow works perfectly, but I’m unable to activate: saving works, not the activation.

I’m wondering if it could be an issue with the RSS Feed Trigger?

Thank you!!

I just made a test with only a RSS Feed Trigger node. It contains a Google alert RSS feed with no articles.
When trying to activate it, I get the same problem.

image

The node doesn’t have any additional settings; it doesn’t look possible to manage it from the editor (maybe it’s a bug in the node’s code)

In the end, I created a bug report: Empty RSS Feed cause error on RSS Feed Trigge · Issue #10853 · n8n-io/n8n · GitHub

Hi @Baptiste_JACQUEMET

No solution found yet for this in N8N.

Hi @Ananth_Rayala , @Baptiste_JACQUEMET

Thanks for creating the bug report! :raised_hands:
Our team has made a fix for this - fix(RSS Feed Trigger Node): Handle empty items gracefully by netroy · Pull Request #10855 · n8n-io/n8n · GitHub - and that should be released with our next version!

2 Likes

wow, amazing, thank you!

Thanks for the update.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.