bally
February 29, 2024, 10:53pm
1
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
n8n
February 29, 2024, 10:53pm
2
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:
liam
March 1, 2024, 12:02am
3
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
bally
March 1, 2024, 12:38am
4
Thanks, I didn’t know you could look into it like this. Here’s the real run.
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
no data? But it did create the correct contact.
then I ran again and pinned the email trigger
again the correct contact
liam
March 1, 2024, 3:52am
5
bally:
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",
}
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?
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") }}?
bally
March 1, 2024, 4:25am
6
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.
barn4k
March 1, 2024, 8:22am
7
bally:
I’m transforming the date like this
{{ DateTime.fromFormat( $json.date, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").toFormat("yyyyMMdd")
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
bally
March 1, 2024, 10:37am
8
this one also worked in the expression and in came a real email and this time I get
Invalid DateTime
barn4k
March 1, 2024, 10:53am
9
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
bally
March 1, 2024, 11:20am
10
I’ll add a few fields lke that.
I wonder if the problem is the end of it “.000Z”
barn4k
March 1, 2024, 1:20pm
11
It shouldn’t be a problem, that’s a part of the ISO standard
bally
March 1, 2024, 10:29pm
12
Here’s another real run
The fields:
output
same thing in test mode
Can’t use DateTime in real mode?
barn4k
March 1, 2024, 10:53pm
13
@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
bally
March 1, 2024, 11:09pm
14
yes latest docker updated 2 days ago.
barn4k
March 2, 2024, 7:17am
15
Does the issue remain the same if you replace the Edit Fields node with the Code node?
barn4k
March 4, 2024, 8:37am
17
Yes, seems working. The Code node processes items a bit differently than the Edit Fields node, but it consumes more resources.
Jon
March 7, 2024, 3:13pm
18
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:
bally
March 8, 2024, 3:45am
19
Jon
March 8, 2024, 8:18am
20
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?