n8n-io / n8n

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

HTTP Request node version 4.1 - .map() function producing invalid JSON Body #10180

Open skyfox675 opened 1 month ago

skyfox675 commented 1 month ago

Bug Description

Hi Team!

When testing a new workflow, I've found that the HTTP Request node (v 4.1) is producing invalid JSON when using the following settings along with a .map() to iterate over an unknown number of items.

To Reproduce

Using the following settings:

return signer }) }} ,{ "name": "", "email": "", "mobile": "", "auto_sign": "yes", "signature_request_delivery_method": "email", "signed_document_delivery_method": "email" } ] }


### Expected behavior

Using my example above, this should produce a list of "signers" that contains 2 objects produced by the .map():
``` Javascript
{
    "template_id": "<redacted>",
    "test": "yes",
    "custom_webhook_url": "<redacted>",
    "metadata": "{\"twentycrm_company_id\":\"<redacted>\"}",
    "placeholder_fields": [
        {
            "api_key": "Date",
            "value": "July 24, 2024"
        },
        {
            "api_key": "Company Name",
            "value": "<redacted>"
        }
    ],
    "signers": [
{
    "name": "<redacted>",
    "email": "<redacted>",
    "mobile": "<redacted>",
    "auto_sign": "no",
    "signature_request_delivery_method": "email",
    "signed_document_delivery_method": "email",
    "required_identification_methods": ["email", "sms"]
},
{
    "name": "<redacted>",
    "email": "<redacted>",
    "mobile": "<redacted>",
    "auto_sign": "no",
    "signature_request_delivery_method": "email",
    "signed_document_delivery_method": "email",
    "required_identification_methods": ["email", "sms"]
}
,{
            "name": "<redacted>",
            "email": "<redacted>",
            "mobile": "<redacted>",
            "auto_sign": "yes",
            "signature_request_delivery_method": "email",
            "signed_document_delivery_method": "email"
        }
    ]
}

However this is the current result being produced. The closing ] on signers.*.required_identification_methods is being stripped from the resultant objects causing invalid JSON syntax:

{
    "template_id": "<redacted>",
    "test": "yes",
    "custom_webhook_url": "<redacted>",
    "metadata": "{\"twentycrm_company_id\":\"<redacted>\"}",
    "placeholder_fields": [
        {
            "api_key": "Date",
            "value": "July 24, 2024"
        },
        {
            "api_key": "Company Name",
            "value": "<redacted>"
        }
    ],
    "signers": [
{
    "name": "<redacted>",
    "email": "<redacted>",
    "mobile": "<redacted>",
    "auto_sign": "no",
    "signature_request_delivery_method": "email",
    "signed_document_delivery_method": "email",
    "required_identification_methods": ["email", "sms"
},
{
    "name": "<redacted>",
    "email": "<redacted>",
    "mobile": "<redacted>",
    "auto_sign": "no",
    "signature_request_delivery_method": "email",
    "signed_document_delivery_method": "email",
    "required_identification_methods": ["email", "sms"
}
 ,{
            "name": "<redacted>",
            "email": "<redacted>",
            "mobile": "<redacted>",
            "auto_sign": "yes",
            "signature_request_delivery_method": "email",
            "signed_document_delivery_method": "email"
        }
    ]
}

Operating System

docker.n8n.io/n8nio/n8n:1.52.0

n8n Version

1.52.2

Node.js Version

Same as docker.n8n.io/n8nio/n8n:1.52.0

Database

SQLite (default)

Execution mode

queue

skyfox675 commented 1 month ago

Hi team, I've confirmed this exists on n8n 1.52.2 as of this morning

skyfox675 commented 1 month ago

Also confirmed this exists on n8n 1.53.0 as of this morning as well

Joffcom commented 1 month ago

Hey @skyfox675,

Thanks for the report, We have created an internal ticket to get this resolved in a future release.