Workflow gives null in real run but works fine in test run

I’m using n8n self hosted on docker and a Gmail trigger

I’m transforming the date like this

{{ DateTime.fromFormat( $json.date, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").toFormat("yyyyMMdd") }}

and inserting it into a contacts notes field

it works completely fine during testing and then I put it live and an email came through. The resulting contacts had “null” instead of the date “20240229”

so I went back into the workflow and ran the same node in test mode picking up the same email and it created the contact with the correct notes field as expected 20240229

I’m pretty new to this so I haven’t put in error handling or anything like that but what can I look at to see why this has happened

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:

Can you share the output data on the test run as well as in the error execution run?

As shown:

Make sure you’re getting it from the failed execution as well. Go into the executions tab and go into the node to see the data it had.

Also, copy and paste your workflow into your reply. Just highlight everything and paste it in after pressing the </> button in the toolbar

Thanks, I didn’t know you could look into it like this. Here’s the real run.

image

I got the Gmail Trigger - I’ll try to strip the sensitive details except for the lines that include a date


{
"headers": 
{

"arc-message-signature": 
"ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:from-phone:last-name :first-name:email:message-id:reply-to:from:date:subject:to :dkim-signature; =; b= F4/g==; dara=google.com",

"dkim-signature": 
"DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=default; h=Content-Transfer-Encoding:Content-Type :MIME-Version:Message-ID:Reply-To:From:Date:Subject:To:Sender:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh==;",

"date": 
"Date: Thu, 29 Feb 2024 19:07:17 +0000",
}


"date": 
"2024-02-29T19:07:17.000Z",

the next node is where it turned null, even tho the expression field says fine


Here is the manual test I ran later
image

no data? But it did create the correct contact.


then I ran again and pinned the email trigger
image

again the correct contact

This one is actually not the date you’re using. This one would be headers.date, since it’s under the headers. There is another date that isn’t under headers. This one actually wouldn’t work since it has the 'Date: ’ in the string (unless you removed it).

I just tested with mine and everything is exactly the same for testing and activated with test emails.

You have simplify turned off like this, right?
Screenshot 2024-02-29 at 10.37.53 PM
The date field doesn’t show when this is on.


While this is strange that it isn’t working for you, can you just use {{ $now.toFormat("yyyyMMdd") }}?

Sorry I missed one. THere is one outside headers

“date”: “2024-02-29T19:07:17.000Z”,

this format is easier than dealing with the one inside the headers.

Well I’ll see what happens a few more times, that part isn’t a big deal. Maybe it’s a one off glitch

I could {{ $now.toFormat(“yyyyMMdd”) }} but then testing would be wrong dates.

Try instead of using DateTime.fromFormat to use {{ DateTime.fromISO($json.date) }} as the string is actually an ISO string. The null value could be if the date parsing will fail

this one also worked in the expression and in came a real email and this time I get
Invalid DateTime

image

That’s strange. Can you create another field in the Edit Fields node and pass the {{$json.date}} there? So we could see the exact date that has been broken somehow

I’ll add a few fields lke that.
I wonder if the problem is the end of it “.000Z”

It shouldn’t be a problem, that’s a part of the ISO standard

Here’s another real run
The fields:

output
image

same thing in test mode

image

Can’t use DateTime in real mode?

@bally
Are you using the latest n8n version?

Hey @Jon

Can you please check this out? Seems like a bug with Set node

1 Like

yes latest docker updated 2 days ago.

Does the issue remain the same if you replace the Edit Fields node with the Code node?

seems fine?

Yes, seems working. The Code node processes items a bit differently than the Edit Fields node, but it consumes more resources.

I have taken a quick look and for me the Set node is working in a production execution.

This means I have some follow up questions that were missed in the original post…

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

SQLite
Community Edition
n8n Version 1.29.1
Source Code GitHub - n8n-io/n8n: Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
Docker

n8n EXECUTIONS_PROCESS - where is this set?

Exections process is an environment option that you would set although ti doesn’t apply anymore so I will remove that option.

What env options do you have set for your n8n instance do you have TZ set to match your timezone as well as GENERIC_TIMEZONE?