n8n-io / n8n

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

Zoho CRM: this.setDefaultStatusCodeMessage is not a function #8508

Closed sprankhub closed 7 months ago

sprankhub commented 7 months ago

Describe the bug On certain Zoho CRM API errors, no proper error message is shown. Instead, the error message this.setDefaultStatusCodeMessage is not a function is shown:

image

To Reproduce Steps to reproduce the behavior:

  1. Add a new workflow, which syncs all your Google Contacts with Zoho CRM:

    {
      "meta": {
        "templateCredsSetupCompleted": true,
        "instanceId": "..."
      },
      "nodes": [
        {
          "parameters": {
            "resource": "contact",
            "operation": "upsert",
            "lastName": "={{ $json[\"names\"][\"familyName\"] }}",
            "additionalFields": {
              "customFields": {
                "customFields": [
                  {
                    "fieldId": "Lead_Quelle",
                    "value": "={{ [\"Google Kontakte\"] }}"
                  }
                ]
              },
              "Email": "={{ $json[\"emailAddresses\"][Object.keys($json[\"emailAddresses\"])[0]][0] }}",
              "Secondary_Email": "={{ $json[\"emailAddresses\"][Object.keys($json[\"emailAddresses\"])[1]][0] }}",
              "First_Name": "={{ $json.names.givenName }}",
              "Mobile": "={{ $json.phoneNumbers.mobile[0] }}",
              "Phone": "={{ $json[\"phoneNumbers\"][\"work\"] ? $json[\"phoneNumbers\"][\"work\"][0] : $json[\"phoneNumbers\"][Object.keys($json[\"phoneNumbers\"])[0]][0] }}",
              "Home_Phone": "={{ $json.phoneNumbers.home[0] }}"
            }
          },
          "id": "...",
          "name": "Zoho CRM",
          "type": "n8n-nodes-base.zohoCrm",
          "typeVersion": 1,
          "position": [
            1280,
            360
          ],
          "credentials": {
            "zohoOAuth2Api": {
              "id": "...",
              "name": "Zoho account"
            }
          }
        }
      ],
      "connections": {},
      "pinData": {}
    }
  2. Execute the workflow.

Expected behavior I expected the workflow to be executed without any error or, if there is an error, I expected a proper error message / display.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

sprankhub commented 7 months ago

Nice, thanks for your fast fix, @netroy! Any idea when there will be a bugfix release due to this? It is quite hard to fix workflows not knowing what is wrong :joy:

netroy commented 7 months ago

Any idea when there will be a bugfix release due to this?

1.27.0 Should be out in the next hour. And if we find any major issues in there, we'll consider creating a 1.26.1 patch.

sprankhub commented 7 months ago

Nice, it's released. Any idea when this is rolled out to the cloud version, @netroy?

netroy commented 7 months ago

We've found some issues in the release, and will be releasing 1.27.2 later today. If that looks to have fixed these issues, we'll post a comment here, and soon after make the version available as beta on cloud.

sprankhub commented 7 months ago

@netroy, I updated to 1.27.2 now and tested my workflow again. The error display didn't improve a lot, to be honest:

image

This is the full stack:

NodeApiError: [RE-WRAPPED]: 
    at Object.zohoApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Zoho/GenericFunctions.js:49:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Zoho/ZohoCrm.node.js:321:40)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:706:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:656:53
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1058:20

Could you please check this issue one more time?

netroy commented 7 months ago

Sorry about this.

8510 did fix a JS error, and that's why the error message has changed here.

But, looks like there is some error from Zoho, that's getting re-wrapped for no good reason the code. I've created a custom image that might help debug this. Can you please try running with the image n8nio/n8n:debug-8508, and let me know what error you get this time? 🙏🏽

sprankhub commented 7 months ago

Thanks for your support, @netroy! I would love to, but since we currently use the cloud version, it is not really easy to do for me. I guess there is no way to switch to that image in the cloud version, right? What's the easiest way to shortly host this myself and to import the workflow with the issue (including credentials) in this temporary instance?

sprankhub commented 7 months ago

@netroy, could you provide some further support here? I am currently unsure how we can solve this together.

netroy commented 7 months ago

Can you please try running the workflow again?

sprankhub commented 7 months ago

Done. Error message: "Problem in node ‘Zoho CRM‘". If it helps and it is safe to share, there is also a console error I can post...

netroy commented 7 months ago

I've pushed another change to explicitly log the error. Can you please try executing the workflow one more time 🙏🏽 ?

sprankhub commented 7 months ago

Refreshed and executed. Did that help?

netroy commented 7 months ago

unfortunately the error handling in this node is a bit of a mess, and I forgot to explicitly log the error response from Zoho. All I can tell is that there is an API error from Zoho, and this node isn't doing a good job of bringing that error up to the UI. Creating a new image with more logging now. Will ping you back once it is deployed.

netroy commented 7 months ago

@sprankhub Can you try one more time please 🙏🏽 ?

sprankhub commented 7 months ago

Done, @netroy!

netroy commented 7 months ago

Did you get any more error related into in the UI?

In the console I got this:

{"data":[{"code":"INVALID_DATA","details":{"expected_data_type":"phone","api_name":"Phone"},"message":"invalid data","status":"error"}]}

I'm not familiar with Zoho API, but I'm assuming that they are doing some kind of input validation on a phone number field, and the value you are sending is invalid.

sprankhub commented 7 months ago

@netroy, any chance to forward this message to the UI? I only get "UNKNOWN ERROR - check the detailed error for more information", but there is no detailed error :D It would be great if it was reporting the invalid data and the concrete error message.

netroy commented 7 months ago

Yeah, this is tech-debt. I've created an internal ticket to track this: ENG-100.

sprankhub commented 7 months ago

Thanks, @netroy! Could you give me an idea how this will evolve? Is this a matter of weeks, months or years? How can I follow the progress?

sprankhub commented 7 months ago

@netroy, could you please give me some information on this? Thanks!

netroy commented 7 months ago

parts of this is already being addressed in #8644. but I unfortunately I don't have any more information to share, and neither can I provide a timeline at this moment.

sprankhub commented 5 months ago

8644 has now already been merged for some time. I am currently using version 1.36.4. However, my Zoho node still doesn't show a proper error from the API, but just generic n8n information instead:

image

@netroy, would you be able to have another look at this? I don't think this issue should be closed as the underyling issue is not fixed yet. Should I open a new ticket instead?

netroy commented 4 months ago

The this.setDefaultStatusCodeMessage is not a function issue is definitely resolved. However we still have an issue that we are not showing all the details in response errors on the UI. We are working on improving this, but don't have a clear deadline. If you know the Zoho endpoint that your node needs to talk to, can you please try using a HTTP node with the same credential instead? That should show you more details on what exactly is failing.

sprankhub commented 4 months ago

@netroy, thanks, I tried this, but I keep getting a credential issue when I use the same Zoho credentials in a generic HTTP node:

{"code":"INVALID_TOKEN","details":{},"message":"invalid oauth token","status":"error"}
netroy commented 4 months ago

"code":"INVALID_TOKEN",

This sounds like an issue to discuss on community.n8n.io. Some possibly related threads: https://community.n8n.io/search?q=zoho%20INVALID_TOKEN%20order%3Alatest

sprankhub commented 4 months ago

Okay the INVALID_TOKEN issue happened, because I used zohoapis.com instead of zohoapis.eu. Pity that there is not a better error message for this.

And now that I ran a simple HTTP node instead of the Zoho node, I also got the full error:

{"code":"TOO_MANY_REQUESTS","details":{},"message":"Many requests fired in concurrent than the allowed limit.","status":"error"}

The issue is that I send one API request to Zoho for each result. Instead, it would be better to only send one API request to Zoho for all results at once. I am not sure how to implement that yet. I'll need to have a closer look.