Error when receiving file from appsmith application

I receive a base 64 file (original xlsx file). I have a function that does this:

return [
  {
    json: {},
    binary: {
        data: {
				data: items[0].json.file,
				mimeType: $node["Webhook"].json["query"]["type"], // Optional but should be set if possible (optional)
				fileName: $node["Webhook"].json["query"]["filename"], // Optional but should be set if possible (optional)
			}    }
  }
]

and this is the error it returns .

ERROR: Method Promise.prototype.then called on incompatible receiver [object Object]`

Can you help me to interpret this error
here is the complete process code :

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -300,
        180
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "httpMethod": "POST",
        "path": "ab31137d-2b8f-402a-abc2-4fca160df44a",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        -190,
        380
      ],
      "webhookId": "ab31137d-2b8f-402a-abc2-4fca160df44a",
      "credentials": {
        "httpHeaderAuth": "CorepHeaderAuth"
      }
    },
    {
      "parameters": {
        "command": "=sh /usr/local/ETL/CRP/JOBS/modif_ligne_tarif_user_web_0.1/modif_ligne_tarif_user_web/modif_ligne_tarif_user_web_run.sh {{$node[\"Webhook\"].json[\"query\"][\"clitar\"]}} {{$node[\"Webhook\"].json[\"query\"][\"cperi\"]}} {{$node[\"Webhook\"].json[\"query\"][\"ctarif\"]}} {{$node[\"Webhook\"].json[\"query\"][\"societe\"]}} {{$node[\"Webhook\"].json[\"query\"][\"user_mail\"]}} {{$node[\"Webhook\"].json[\"query\"][\"date_deb\"]}} {{$node[\"Webhook\"].json[\"query\"][\"date_fin\"]}} {{$node[\"Webhook\"].json[\"query\"][\"type_ope\"]}}"
      },
      "name": "Execute Command update",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        710,
        380
      ],
      "disabled": true
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {},\n    binary: {\n        data: {\n\t\t\t\tdata: items[0].json.file,\n\t\t\t\tmimeType: $node[\"Webhook\"].json[\"query\"][\"type\"], // Optional but should be set if possible (optional)\n\t\t\t\tfileName: $node[\"Webhook\"].json[\"query\"][\"filename\"], // Optional but should be set if possible (optional)\n\t\t\t}    }\n  }\n]"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        210,
        380
      ]
    },
    {
      "parameters": {
        "fileName": "=usr/local/ETL/CRP/Travaux/Commercial/modif_tarif/Input/Matrice_Tarif.xlsx"
      },
      "name": "Write Binary File",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [
        390,
        380
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "file",
              "value": "={{$node[\"Webhook\"].json[\"body\"][\"name\"][\"data\"].replace('data:'+$node[\"Webhook\"].json[\"query\"][\"type\"]+';base64,','')}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        30,
        380
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Set2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Write Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Binary File": {
      "main": [
        [
          {
            "node": "Execute Command update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set2": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

What version of n8n are you using?

I had the same issue a couple of days ago and fixed it by updating to the latest version of n8n. Can you try that out?

this is my version
n8n Version:

0.142.0

There was a bug in vm2 which broke the Function-Node is why we did roll back the version of it.

The issue you describe is not in any of our docker-images. I made sure of that, so I assume you either created your own one or you run the code another way. No matter what, if you pull the latest code and you run npm run bootstrap the problem should be gone.

I updated n8n to the latest version, problem solved

Thanks

1 Like