n8n-io / n8n

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

Monday.com - Problem in node ‘Add update to item‘ #8531

Open niclm opened 7 months ago

niclm commented 7 months ago

Describe the bug When using the Monday.com Add Update operation using OAuth credentials, the following error occurs:

ERROR: Cannot read properties of undefined (reading 'create_update')

To Reproduce

  1. Open nodes panel and search for Monday.com
  2. Select the Add an update to an item action
  3. Open the newly added node and enter in the following:
    • Credential to connect with: Select an OAuth credential that has been given full scope permissions
    • Resource: Select Board Item
    • Operation: Select Add Update
    • Item ID: Add a valid board item id
    • Update Text: Add a string value of Test
  4. Click Test step
  5. See error

Expected behaviour A new update should be created. NB: This works perfectly fine when using an API key, just not with OAuth.

Environment:

Additional context

TypeError: Cannot read properties of undefined (reading 'create_update')
    at Object.execute (/usr/lib/node_modules/n8n/node_modules/n8n-nodes-base/nodes/MondayCom/MondayCom.node.ts:479:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/usr/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1322:8)
    at /usr/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:1046:29
image
Joffcom commented 7 months ago

Hey @niclm,

Thanks for reporting this one, it looks like the api may no longer be returning the field we are expecting. I will dig into the api docs for Monday in the morning and see if I can spot what has changed.

Joffcom commented 7 months ago

Hey @niclm,

I have taken a look and at first I wasn't able to reproduce it but once I changed from API Token to OAuth that got it failing, I have created NODE-1102 as the internal ticket to fix tthis. For now if possible if you use an API Token it should get you up and running.

niclm commented 7 months ago

I discovered something that may be worth looking into. I tried interacting with the Monday API directly using an HTTP Request node, however I noticed in the response that I lacked permissions to create an update:

image

I went back to verify the scope in Monday.com and can see that I have enabled the permission correctly. I verified this by clicking on the OAuth Authorisation URL that Monday provides, I saw that the scope was within the list:

image

When I connect via n8n I am presented with a different scope, which is missing updates:write:

image

I then manually created a Generic Credential Type and I was able to see the correct scope, and once authorised I was able to successfully create an update 🥳

Does the predefined credential type for Monday have the correct Authorisation URL ?

Joffcom commented 7 months ago

Hey @niclm,

That could be it, Our credential only sets boards:write and boards:read so when we connect to Monday this is all we will request. It makes sense for the error to be with the response not matching what we are using, I can get that updated shortly.

With the authorization url we use https://auth.monday.com/oauth2/authorize which is what the Monday docs point to for the OAuth flow.

niclm commented 7 months ago

Ah ha! Would it make sense to add checkboxes to specify the scope you need? Or would it make sense to just not set the scope at all from n8n, since that can be managed on Monday?

Joffcom commented 7 months ago

That is something I will need to check in their API docs to see what they recommend.