Having trouble parsing this message

I have an exec node running some code.

I connect to the return code output. (The bottom one)

This is the message coming out:


I open the payload part and copy the value. I'm guessing it is 0.
But when I paste it I get:

0 but it isn't quite that easy.

I put that into a switch node and it never gets through.

Wondering what is going on, I copy the value and paste it.

Things get weird now.

Screen shot time.

This is an arbitrary function node.

Note where the cursor is.

So then I press paste and this is what I get:

Somehow there is a carriage return built into what I copied.

I'm confused.

What is going on?

I can reproduce. It only happens if i copy the value from the debug window or click copy value. If another source is used (vscode/sublime), it does not happen.

There might be an special hidden character. (i couldn't find it).

1 Like

Phew. It isn't just me.

Ok. Not a big deal. I will work around the problem.

Appreciated you validating it wasn't me doing something stupid.

That suggests you did not do it correctly. Show us what you tried.


I have the debug node, expand the tree to see what I want to get, click on the clipboard icon.
It says copied to clip board.

I then pate it in the function node at the end of the line and the 0 from the clipboard is at the start of the line.

Doesnt happen in Chrome on Windows - might be a browser or OS thing?

I tried with the debug set to show msg.payload AND showing full message - same result.

(How are you doing this magic?) :wink:

Screen recordings.

sharex (windows only)

For linux, there is peek and others though not as feature rich as sharex

Ah, windows.

Not much good for Ubuntu.

Ok, I have word around it by changing the == to contains.

That works.

You said you tried it in a Switch node but it didn't work, but you haven't showed us what you tried in the switch node. Then you went on to talk about a function node problem.

Originally the node was like this:


But works when it is set as:


So I was just curious why the payload isn't as I am copying from the debug node.

I only went into the function node to paste the copied msg.payload to see what node-red thinks of it.

== is working for me.
besides if you put contains not only 0 will pass but 10 , 2022 etc whatever contains zero and that may not be what you want.

you sure you are setting msg.payload.code in the switch node ? and not simply msg.payload ?


Yes, I am sure that is the message structure.

Alas it is an artefact of my early MQTT stuff.

It is the output of an exec node. It only really puts out 0 for good, and 127 for errors.

That is all I want to get from the output.

I think you're on to something.

The fact Andrew states he solved it by using contains instead of == suggest he was comparing to string 0 not number 0

Not that it should matter but payload.code is definitely a number so your example would be the correct solution.

I was suspicious that it was a text, which also lead me to paste it in a function node.

When it was pasted in the node, it was orange so I take it that it is a number.

More like...


Ok. I was talking about the 0 to the left of this is just some text.

But yes: correct.

Is this from o/p 3 of a switch node?
Is the exec node feeding direct into the switch node or is there anything at all in between?
Can you show us the config of the exec node? I want to try and replicate the problem.
I don't even know what "contains" means if the type is number.

Yes, but you copied that from the debug

A 0 in the JS editor is a number because it has no quotes.

The debug does not copy " quotes so a string "0" zero would copy and paste as 0

In other words, pasting the value means nothing - how its presented in the object is what matters.

in other words, it IS / WAS a number so use the == number in the switch (not contains)

No, via a delay node set to delay the message for 5 seconds.