Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If node will return true / false wrongly if empty new line after JavaScript #12237

Open
itsimonchan opened this issue Dec 15, 2024 · 3 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@itsimonchan
Copy link

Bug Description

A JavaScript formula which should return nothing in True Branch will shows all results in True Branch if there is at least 1 new line (enter) appended after code

To Reproduce

  1. Create a new workflow
  2. Get data from Google Calendar
  3. Enters JavaScript appended below
  4. Click Test Step, very likely that true branch will show nothing
  5. Go to end of JavaScript code, press enter
  6. Click Test Setup again, true branch will show all results

JavaScript code:
{{
$json["start"].dateTime &&
new Date($json["start"].dateTime).getTime() > new Date().getTime() &&
new Date($json["start"].dateTime).getTime() - new Date().getTime() <= 30 * 60 * 1000
}}

Expected behavior

True branch will show only what should be true.

Operating System

Zeabur

n8n Version

1.71.3

Node.js Version

Not sure (Managed by Zeabur)

Database

PostgreSQL

Execution mode

main (default)

@Joffcom
Copy link
Member

Joffcom commented Dec 15, 2024

Hey @itsimonchan,

We have created an internal ticket to look into this which we will be tracking as "N8N-7972"

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Dec 15, 2024
@RicardoE105
Copy link
Contributor

Can you please provide a sample workflow. Sadly, I have not been able to replicate the issue. I used the workflow below in version 1.73.0

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -360,
        -80
      ],
      "id": "620ededf-7783-48d2-948a-9b21baa05a0e",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "fd6a5c95-197f-4472-9eba-fa5e5d8f8610",
              "leftValue": "={{\nDateTime.isDateTime($json.start) && \nDateTime.isDateTime($json.end)\n\n}}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        120,
        -80
      ],
      "id": "ada4206c-6a4c-45eb-beaa-db3101ed3ca5",
      "name": "If"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c1e31e2e-4299-43a2-aa02-11f2d4eb98af",
              "name": "start",
              "value": "={{ $now }}",
              "type": "string"
            },
            {
              "id": "ab376efe-1b69-4a38-a8d6-5b8f83e092fc",
              "name": "end",
              "value": "={{ $now }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -100,
        -80
      ],
      "id": "ad65e6ae-5f55-482f-a5bb-2121c97ccb8e",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}

@itsimonchan
Copy link
Author

itsimonchan commented Dec 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

3 participants