Error "Cannot read properties of undefined (reading '0')" When Attaching Email Files to Jira Issues in n8n Workflow

Describe the problem/error/question

Hello, I’m trying to build a workflow that reads emails and creates Jira issues with any email attachments, but I’m encountering an error when trying to attach files. The “Issue Attachment” tool always fails with the error message: Cannot read properties of undefined (reading '0').

What I’ve tried

I’ve verified that the email contains attachments and that the issue is being created successfully. The error only occurs during the attachment step. I’m using a Code node to process the binary data from the email before passing it to the Jira attachment node.

What is the error message (if any)?

Cannot read properties of undefined (reading '0')

The related log entry is :

{
    "message": {
        "channel": "web",
        "context": {
            "app": {
                "name": "RudderLabs JavaScript SDK",
                "namespace": "com.rudderlabs.javascript",
                "version": "1.33.0"
            },
            "traits": {
                "instance_id": "b1862f9c61dcf71c48b1a8ecb62b9c9bd55e3cd262e106f200158bfbf48e01c3"
            },
            "library": {
                "name": "RudderLabs JavaScript SDK",
                "version": "1.33.0"
            },
            "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
            "locale": "de-DE",
            "os": {
                "name": "",
                "version": ""
            },
            "screen": {
                "density": 2,
                "width": 3360,
                "height": 1890,
                "innerWidth": 1828,
                "innerHeight": 1402
            },
            "device": null,
            "network": null,
            "sessionId": 1743595041699,
            "campaign": {},
            "page": {
                "path": "/workflow/VhuI6aOUn3vMmVx8",
                "referrer": "$direct",
                "referring_domain": "",
                "search": "",
                "title": "🔄 Create Jira Issue - n8n[DEV]",
                "url": "/workflow/VhuI6aOUn3vMmVx8",
                "tab_url": "/workflow/VhuI6aOUn3vMmVx8",
                "initial_referrer": "$direct",
                "initial_referring_domain": ""
            },
            "ip": "0.0.0.0"
        },
        "type": "track",
        "messageId": "6b4e672c-d20c-4a42-9dc6-a54508ca5eb4",
        "originalTimestamp": "2025-04-02T11:59:28.559Z",
        "anonymousId": "41df77f8-c7f4-4901-90b7-980eedfc4f67",
        "userId": "b1862f9c61dcf71c48b1a8ecb62b9c9bd55e3cd262e106f200158bfbf48e01c3#1abd5523-8209-44ba-9ea2-d281a2afef3b",
        "event": "Manual exec errored",
        "properties": {
            "error_title": "Cannot read properties of undefined (reading '0')",
            "node_type": "n8n-nodes-base.jiraTool",
            "node_type_version": 1,
            "node_id": "4768af9c-7d44-4d62-a599-97c789d3c0f9",
            "node_graph_string": "{\"node_types\":[\"n8n-nodes-base.emailReadImap\",\"n8n-nodes-base.if\",\"@n8n/n8n-nodes-langchain.agent\",\"n8n-nodes-base.jiraTool\",\"@n8n/n8n-nodes-langchain.lmChatOpenAi\",\"n8n-nodes-base.code\",\"n8n-nodes-base.jiraTool\"],\"node_connections\":[{\"start\":\"0\",\"end\":\"1\"},{\"start\":\"1\",\"end\":\"5\"},{\"start\":\"3\",\"end\":\"2\"},{\"start\":\"4\",\"end\":\"2\"},{\"start\":\"5\",\"end\":\"2\"},{\"start\":\"6\",\"end\":\"2\"}],\"nodes\":{\"0\":{\"id\":\"fec304ef-2e24-42d7-a824-a9da14ce4be4\",\"type\":\"n8n-nodes-base.emailReadImap\",\"version\":2,\"position\":[-420,-160]},\"1\":{\"id\":\"76e6cb9c-63b4-47de-b96d-5718a1dae7dd\",\"type\":\"n8n-nodes-base.if\",\"version\":2.2,\"position\":[-180,-160]},\"2\":{\"id\":\"ffc316e9-8cd0-4799-96e6-4bfc4740c809\",\"type\":\"@n8n/n8n-nodes-langchain.agent\",\"version\":1.8,\"position\":[200,-140],\"agent\":\"conversationalAgent\"},\"3\":{\"id\":\"7e14871d-75ef-402a-b565-ca17f8ac6550\",\"type\":\"n8n-nodes-base.jiraTool\",\"version\":1,\"position\":[380,180],\"operation\":\"create\",\"resource\":\"issue\"},\"4\":{\"id\":\"9f818d1e-1d07-4947-a190-f9310f545b6e\",\"type\":\"@n8n/n8n-nodes-langchain.lmChatOpenAi\",\"version\":1.2,\"position\":[160,120]},\"5\":{\"id\":\"91055e49-83f8-4099-aaf9-bfae3326445b\",\"type\":\"n8n-nodes-base.code\",\"version\":2,\"position\":[40,-220],\"mode\":\"runOnceForAllItems\"},\"6\":{\"id\":\"4768af9c-7d44-4d62-a599-97c789d3c0f9\",\"type\":\"n8n-nodes-base.jiraTool\",\"version\":1,\"position\":[580,100],\"operation\":\"add\",\"resource\":\"issueAttachment\"}},\"notes\":{},\"is_pinned\":false}",
            "version_cli": "1.85.4"
        },
        "integrations": {
            "All": true
        },
        "user_properties": null
    }
}

Please share your workflow

Questions

  • Is there something specific I need to do to prepare the binary data before passing it to the Jira attachment node?
  • Is my ‘Code’ node correctly processing the email attachments?
  • Does this error happen because the AI Agent isn’t properly passing the issue key to the jira_add_attachments node?

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.85.4
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npx
  • Operating system: Debian 12

hello @miron.kr

I do not see that the atachments is passed to the node, as there si no ‘Binary’ tab in the input. What is the output of the Code node?

Hello @barn4k , hm it’s not present in the “Debugging” tab but when I switch to “Mapping” it’s visible:


The tools can only access first item of whatever input the AI Agent node receives. It is documented, but I do not have the link handy to prove.

So, you need to employ Loop with batch size 1 to process all entries from the Code node.

This may not resolve your issue but current setup may cause some issues.

Thanks @Olek for pointing this out. I added the "Loop Over Items " block but as intended this did not fix the issue. I will try to upload the files with a “HTTP Request” block. I’ll post my solution if it’ll work.

1 Like

Hello, here’s my updated workflow using a HTTP Request block for uploading the files. It feels a little bit clunky and it would be much cleaner solving this with the tool which is directly connected to the AI Agent but it works very well for me.

Thank you all for guidance, learned a lot :slight_smile:

3 Likes

I guess you can mark it as a :white_check_mark: Solution, so that anyone stumbling upon a similar situation could find it.

A couple of notes and (untested) proposals tho:

  1. If you put the Merge node in Combine by position mode you wouldn’t need the Code node past it. It will also cover the case when IMAP trigger feeds more than one emails into the workflow.
  2. You could employ the Structured Output Parser tool to extract the issueId from the AI Agent response.
  3. You may want to wrap all the email handling nodes into a Loop with batch size 1, just to cover the very probable case when IMAP trigger would feed more than one email into the workflow.

However, avoid nested loops. This can be achieved by putting the current attachments processing loop into a sub-workflow.

Hope this helps to build a robust workflow.

Happy n8ning!

1 Like

Thanks @Olek , will implement your proposals :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.