Strange Behavior

Describe the problem/error/question

I have a few issues that just do not add up. Here is the scenario. I have a Amazon SNS that of course does not come in the correct JSON format. I use the function node to resolve that:

Interestingly, the BouncedRecipients do not show up on the JSON output. Now I use ItemLists to split up the bounce.bouncedRecipients, that actually dissapeared in the JSON, and voila, they show up again in the output:

Now in the Mautic node I access the Email address of this bouncedRecipients output and it says it is not valid, throwing an error:

What is the error message (if any)?

400 - {“errors”:[{“code”:400,“message”:“email: {{$node[ItemLists].json.contact.emailAddress}} is invalid.”,“details”:{“email”:[“{{$node[ItemLists].json.contact.emailAddress}} is invalid.”]}}]} - email: {{$node[ItemLists].json.contact.emailAddress}} is invalid.

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)


## Share the output returned by the last node
<!-- If you need help with data transformations, please also share your expected output. -->

## Information on your n8n setup
- **n8n version:** 1.21.1
- **Database (default: SQLite):** mySQL / Percona
- **n8n EXECUTIONS_PROCESS setting (default: own, main):** queue
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** Docker
- **Operating system:**

Hi @Martin_Neumann :wave:

Can you provide some sample data that is coming in to the AWS-SNS-Trigger1 node in JSON format? Otherwise it would be very difficult to try and test this.

It’s also worth mentioning that perhaps switching to the new version of the Code node (you can delete and re-add the node) might fix this up here!

Like I said, Amazon SES does not provide real JSON data, but here is the input:

[

{

“Type”: “Notification”,

“MessageId”: “c784ee46-b859-5827-b297-b06c7bb1ef57”,

“TopicArn”: “arn:aws:sns:sa-east-1:469401296259:bounces-saudeplena”,

“Message”: "{“notificationType”:“Bounce”,“bounce”:{“feedbackId”:“0103018d3a7479b1-dca60780-6019-4155-a714-eec031044abb-000000”,“bounceType”:“Permanent”,“bounceSubType”:“OnAccountSuppressionList”,“bouncedRecipients”:[{“emailAddress”:“[email protected]”,“action”:“failed”,“status”:“5.1.1”,“diagnosticCode”:"Amazon SES did not send the message to this address because it is on the suppression list for your account. For more information about removing addresses from the suppression list, see the Amazon SES Developer Guide. “}],“timestamp”:“2024-01-24T07:52:08.000Z”,“reportingMTA”:“dns; amazonses.com”},“mail”:{“timestamp”:“2024-01-24T07:52:08.137Z”,“source”:”=?UTF-8?Q?Martin_Neumann_-_Sa=C3=BAde_Plena?= “,“sourceArn”:“arn:aws:ses:sa-east-1:469401296259:identity/saudeplena.org”,“sourceIp”:“35.207.96.60”,“callerIdentity”:“saudeplena”,“sendingAccountId”:“469401296259”,“messageId”:“0103018d3a7478c9-0f1392df-db66-4332-b328-e96066ef68e5-000000”,“destination”:[“[email protected]”]}}”,

“Timestamp”: “2024-01-24T07:52:08.572Z”,

“SignatureVersion”: “1”,

“Signature”: “F7VLviS80UFuc7LeGTHjdxDdKWdSqOZZbYJdgcecZ2AiyLytkl6wnkarPNR0fX6sYG6ILPqPsuaitMWfBH2KgM3bOAWiMpNDAn5scxYbuMQzMAyuzWngu40aSTf64+3ohT09GKhzHI87jW1duQAxWWS2NPKeOETU1z/zYobpJ3yavUxaFKAP0CU9V8rcne6gZd6f8n1OvsUan9kdvJkjzmHLz7JigJp+RBKq46LOi3+zGTtnnv0DAD0xhWrLEeuOsfGHRDY2cPfxP2iu5BqAqUotdIH3oyIfkdvQheK2mXoHrB+EEbQX1vB4CA+Na2x077PBosLXwXog0yVWmQP0YQ==”,

“SigningCertURL”: “https://sns.sa-east-1.amazonaws.com/SimpleNotificationService-60eadc530605d63b8e62a523676ef735.pem”,

“UnsubscribeURL”: “https://sns.sa-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:sa-east-1:469401296259:bounces-saudeplena:aa2b2dd0-f9b3-4dbc-990f-8f2fff90d436”

}

]

Hi @Martin_Neumann - thanks for that!

I can’t reproduce this by quickly trying this out:

I can also grab the data direct from the pinned data that I have without the Split Out node :thinking: This might be because I obivously don’t have the source data - but you are using some older nodes which have been updated (the code node, item lists has been split into multiple new nodes, etc.) so these nodes may need to be replaced :see_no_evil: The only difference between the Split Out node and not is using {{ $json.Message.bounce.bouncedRecipients[0].emailAddress }} or {{ $json.Message.bounce.mail.destination[0] }}, which may also help you debug this a bit :bowing_man:

Note that in the data I get from the SNS trigger node, the message is a Json encapsulated into parentheses. That means I cannot read it unless it goes through a JSON parse in the code node first. Did you try importing my workflow and trying it with my test data?

Hi @Martin_Neumann - just taking another look, and it looks like you’re using an older syntax in your workflow in that third screenshot, and you haven’t changed the email to be an expression. You can find that toggle if you hover over the field.

In my example, the syntax would look like this from the “Split Out” node:

In your case, it looks like it would instead be something along the lines of {{$(ItemLists).item.json.contact.EmailAddress }}.

The message for the bouncedRecipients json is also not complete, it’s missing the closing } for bounce and the ] for bouncedRecipients - did you edit the message content before sending it? :thinking:

So you say that the syntax of all expressions has changed? That was introduced in which version?

About the input data I copied it as is, but the editor was messing up something with the link at the end of the JSON object. I removed now the link and you should be able to copy the input data correctly.

Hey @Martin_Neumann,

I think the change was in the v1 release but while we prefer the newer approach now what you have may still work. The issue though is you have not set the field to use an expression so it is treating it as a string, if you can update that and give it a run it will be handy to see if it works.

1 Like

Oh yes of course! A little oversight causing that problem. Will correct that and wait for the next bounces to come in.

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