n8n-io / n8n

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

JavaScript Expression replaceAll () doubles replacement #10796

Closed Man-Bot closed 1 week ago

Man-Bot commented 1 week ago

Bug Description

n8n runs in Docker We use replaceAll (" ", ".") to create email from Name and FamilyName and receive unexpected behavior from replaceAll () with doubling anything putted in replacement part.

To Reproduce

Employee name: Bruce Wayne https://company.okta.com/api/v1/users/{{ $json["Manager/Lead"].toLowerCase().replaceAll(" ", ".") }}@company.com Return: bruce..wayne@company.com

Expected behavior

Employee name: Bruce Wayne https://company.okta.com/api/v1/users/{{ $json["Manager/Lead"].toLowerCase().replaceAll(" ", ".") }}@company.com Should Return: bruce.wayne@company.com

Operating System

Ubuntu 24.04 LTS (GNU/Linux 6.8.0-1011-aws x86_64)

n8n Version

1.58.1

Node.js Version

v20.15.0

Database

SQLite (default)

Execution mode

main (default)

Joffcom commented 1 week ago

Hey @Man-Bot,

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

netroy commented 1 week ago

I'm not able to reproduce this. Here is the workflow I tried:

{
  "meta": {
    "instanceId": "5d752e7ecaa02c72bd0177be6c8afab6f138672c45b28a102debad8299471df9"
  },
  "nodes": [
    {
      "parameters": {},
      "id": "59071366-f3ab-40eb-8e5b-58e7d64698f0",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        820,
        420
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ae74a1f1-b229-4415-ab95-1367a6bb1471",
              "name": "name",
              "value": "={{ $json.name.toLowerCase().replaceAll(\" \", \".\") }}@company.com",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "9f3d44a8-88cd-4958-9d95-253d2240ce46",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1040,
        420
      ]
    }
  ],
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "When clicking ‘Test workflow’": [
      {
        "name": "Bruce Wayne"
      }
    ]
  }
}
Man-Bot commented 1 week ago

How can I help you to reproduce this? Arc - ScreenShot 2024-09-12 at 17 16 59@2x

netroy commented 1 week ago

can you share the output of the expression $json["Manager/Lead"].split('') ?

Man-Bot commented 1 week ago

Sure! Arc - ScreenShot 2024-09-12 at 17 35 47@2x

Man-Bot commented 1 week ago

THnx for this example!!! There is OUR side problem: Arc - ScreenShot 2024-09-12 at 17 36 50@2x

Man-Bot commented 1 week ago

...will use trim () for all this names... and I will sacrifice the Okta admins for the glory of the Emperor!