n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
48.32k stars 7.5k forks source link

Expression preview field evaluates false value to empty #3270

Closed laurent-lemke closed 1 year ago

laurent-lemke commented 2 years ago

Describe the bug When we want to show a node from a past workflow execution, field expression show an empty value if the referenced variable used has a false value :

Capture d’écran 2022-05-09 à 12 26 15

However when we open the field expression, the expression is correctly evaluated and the false value is indeed shown. So the impact is minor but might confused at the first time.

To Reproduce Steps to reproduce the behavior:

  1. Run the below workflow
  2. Click on the HTTP request node
  3. The field expression related to the body parameter has a wrong value (one of its attribute is displayed as empty)
    {
    "name": "My workflow 3",
    "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -40,
        -80
      ]
    },
    {
      "parameters": {
        "functionCode": "item.falseVar = false;\nitem.trueVar = true;\n\nreturn item;"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        240,
        -80
      ]
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "http//www.google.fr",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "abc",
              "value": "={ \"x\": {{$json[\"falseVar\"]}}, \"y\": {{$json[\"trueVar\"]}}}"
            }
          ]
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        460,
        -80
      ]
    }
    ],
    "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        []
      ]
    }
    },
    "active": false,
    "settings": {},
    "id": 8
    }

Expected behavior Display the right value

Environment (please complete the following information):

Additional context Add any other context about the problem here.

laurent-lemke commented 2 years ago

After investigating, the bug is more important that is seems.

The UI problem is related to the modal window, not the preview field which display the right data. Thus, there is really a problem within the engine when evaluating a variable that has a false value.

Here is an attached screenshot where you can see that the "x" value must be false ; however it has been evaluated to empty and sent like that to the webserver.

Capture d’écran 2022-05-09 à 15 05 15
laurent-lemke commented 2 years ago

Any news about it ? It is a quite annoying bug since we are not able to send false value in JSON.

menasbeshay commented 2 years ago

@laurent-lemke I'm facing same issue and I did a workaround for it by adding a new string field that holds the boolean value in string format (you can make that using Set node) : item.json.stringField = item.json.boolField ? "true" : "false"; then use this string field in your expressions

wieseljonas commented 2 years ago

Experiencing the same issue. False always evaluates to empty when using in graphQL node variables

Joffcom commented 1 year ago

Just adding that the internal tracking reference for this one is ADO-217.

Joffcom commented 1 year ago

Hey There,

This issue has now been fixed and from n8n 0.219.1 everything should be working as expected. I am going to mark this one as closed for now if you see the issue again let me know.