Some question regarding (the asana) node development

Hey!

I’m extending the Asana node and a few questions came up.

  1. How can I see the Requests n8n actually does? Do I need to run it through some proxy or is it possible to see it in the logs?

  2. I want to add this endpoint https://developers.asana.com/docs/get-multiple-projects

It allows to scope the returned projects by workspace, team and/or archived.

I added a loadOptions helper method to show all existing teams in the UI. Unfortunately this endpoint depends on a workspace: GET /organizations/{workspace_gid}/teams
(see: https://developers.asana.com/docs/get-teams-in-an-organization)

I know about loadOptionsDependsOn.

Now I can add the workspace parameter outside of the collection. It looks a bit ugly because when left empty it shows an error because empty string is not allowed, but the request works.
However, if I set the value, then both values will be used to scope the search, which means it will return all projects in that workspace/organization but not only those for the team.

Code is here:

I don’t depend on that functionality but I would like to figure out how such scenarios should be handled.

  • don’t provide a loadOptions helper for 'teams`?
  1. Is it possible to require that at least one value in a collection is set? required: true doesn’t seem to work, see: https://github.com/infographicsgroup/n8n/pull/1/files#diff-066d3d6095df33b48a155406e98556ceR264

  2. Some of the query strings for the asana task search look like this projects.any (with a dot), see:
    https://developers.asana.com/docs/search-tasks-in-a-workspace. However, using this notation seems to silently break the UI, the field will not be shown anymore when selected.

  3. Last but not least I was wondering what’s the stance regarding tests? It seems uncommon to write tests for the nodes. I do get that it might not make a lot of sense because it will break anyway when the api changes. I wanted to ask anyway.

  4. Is there a specific node which you would recommend to look at to see how the implementation should preferably be done?

  5. Is there something like loadOptionsDependsOn, but not for loadOptions? E.g. to update the asignee_status of a task in asana it is mandatory to also pass an assignee. Because this is the default create/update action it’s not mandatory in general to pass an assignee (only for setting the status).

Hey @einSelbst sorry for the late response. I have not had the chance to review what you want to do with the Asana node. Will try to find the time tomorrow to do it and come back to you with an answer.

  1. How can I see the Requests n8n actually does? Do I need to run it through some proxy or is it possible to see it in the logs?

Do you want to see the request are made to Asana? or do you want to see the request the UI makes to the n8n API?

  1. Last but not least I was wondering what’s the stance regarding tests? It seems uncommon to write tests for the nodes. I do get that it might not make a lot of sense because it will break anyway when the API changes. I wanted to ask anyway.

We do no write test for nodes, mostly because we are a small team we do not have the resources to do so. Hopefully this will improve in the future.

Thank you for your response @RicardoE105! It is much appreciated.

I’m interested in the requests to asana.

Regarding tests: I’m not very fluent with js testing but I’m deeply rooted in a general testing philosophy from my ruby background. If there would be one node, which shows how tests can/should be made it would be of great help.

I did find this but don’t know to what extend the approach would fit for n8n.
https://hackernoon.com/api-testing-with-jest-d1ab74005c0a

Looking forward to some updates for the other questions. Thank you! Silvio

Ok sorry for the late response. @einSelbst

I’m interested in the requests to asana.

For checking the requests to Asana you have two options.

1 - Add a console.log(options) to this line https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/Asana/GenericFunctions.ts#L36

2 - Add the following env variable export NODE_DEBUG=request and then run n8n again.

Regarding tests: I’m not very fluent with js testing but I’m deeply rooted in a general testing philosophy from my ruby background. If there would be one node, which shows how tests can/should be made it would be of great help.

As far as I know, there is no node with tests yet. As I mentioned before we currently just test the node ‘manually’.

I added a loadOptions helper method to show all existing teams in the UI. Unfortunately this endpoint depends on a workspace: GET /organizations/{workspace_gid}/teams

Ok looked into this, the workspaces have to be at the root level and the team should be optional (within a collection). It should load all workspaces, and if you add the team field it should load all the teams on that workspace. Then in the code, you check if team was defined just send the team on the query string else send the workspace. Keep in mind that the endpoint to retrieve the teams just works when the workspace ID provided is an organization as well. It’s weird, seems like asana has two types of workspaces. To check which type of workspace you can use the endpoint GET /workspaces/id and then there is a field called is_organization.

Either way I did in the commit below, if you can test and provide feedback would be cool.

Is it possible to require that at least one value in a collection is set? required: true doesn’t seem to work.

Currently, it’s not posible to define required fields on a collection but, you can check if they are not defined and then throw an error to the user,

Some of the query strings for the asana task search look like this projects.any (with a dot), see:
https://developers.asana.com/docs/search-tasks-in-a-workspace. However, using this notation seems to silently break the UI, the field will not be shown anymore when selected.

Currently, task/search has no such fields? are you trying to add them and it’s not working? I tried to look it up that that endpoint needs a premium account which I do not have.

Is there something like loadOptionsDependsOn , but not for loadOptions ? E.g. to update the asignee_status of a task in asana it is mandatory to also pass an assignee . Because this is the default create / update action it’s not mandatory in general to pass an assignee (only for setting the status).

Currently, the only way to validate this it’s on the code. Check if the assignee is defined when sending the assignee_status if not then throw an error. But if the API sends a friendly error you can let the user see this error and they should be able to figure it out. Assuming the error is understandable.

If something it’s not clear you can simply get back to me.

1 Like

Thank you Ricardo, this is all very helpful! I wanted to get the PR ready before my holiday but hadn’t had time, so it might take two more weeks until I have time again.

1 Like