Closed rthomas67 closed 1 month ago
Hey @rthomas67,
We have created an internal ticket to look into this which we will be tracking as "GHC-148"
Hey @rthomas67,
I have just tried to reproduce this on 1.54.0
and it appears to be working as expected
curl https://n8n.mydomain.com/api/v1/workflows\?tags\=testing,allowPreview -H "X-N8N-API-KEY:n8n_api_XXXXX"
{"data":[{"createdAt":"2024-08-12T06:38:16.343Z","updatedAt":"2024-08-12T06:39:18.778Z","id":"ggv4I52wgfXUBEsw","name":"My workflow 138","active":false,"nodes":[{"parameters":{},"type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[940,420],"id":"696affd8-ee48-48d2-a89b-80d0b02486f8","name":"When clicking ‘Test workflow’"},{"parameters":{"filters":{"tags":"testing,allowPreview"},"requestOptions":{}},"type":"n8n-nodes-base.n8n","typeVersion":1,"position":[1140,420],"id":"c9c22029-3d8b-4565-b331-0eaf5dd16e8e","name":"n8n","credentials":{"n8nApi":{"id":"t2YEgbUMXHjsykeF","name":"admin"}}}],"connections":{"When clicking ‘Test workflow’":{"main":[[{"node":"n8n","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"pinData":{},"versionId":"ac791b12-2f85-46c9-b2e2-276906e95d62","triggerCount":0,"tags":[{"createdAt":"2022-07-07T05:46:15.052Z","updatedAt":"2022-07-07T05:46:15.052Z","id":"14","name":"testing"},{"createdAt":"2023-03-28T16:39:50.917Z","updatedAt":"2023-03-28T16:39:50.917Z","id":"86","name":"allowPreview"}]}],"nextCursor":null}
I have also given it a quick go in Postman as well.
Would you be able to try updating your n8n version to see if this is something that has been fixed in a later version. It may also be worth noting it is workflows containing both tags not either of the tags.
With tags containing a comma I can't work out a way to make that work so that will need to be passed to the the team to look at but if you can check the update first we can make the ticket a lot smaller.
@Joffcom, as you suggest, if a workflow is assigned all-of the tags in the specified CSV list, it is selected, even in the version I was testing.
So, this is probably due to a difference in assumptions about vaguely documented behavior. IMO, based on the current documentation, most people would expect the CSV list of tags to result in the inclusion of all workflows matching any-of the tags, not only workflows matching all-of the tags.
Thank you for clarifying how n8n is actually behaving. I'm sure your comments on this issue will help others who made the same any-of assumption I did.
So, now that that is settled, could we turn this into a feature request? It would be loads more useful to me to have an any-of option for tags. The current all-of behavior does not apply to any use case I can think of, since that would suggest the need to apply 2 or more tags to a given workflow in order for it to be selected by a specified CSV list of tags on the n8n-node / API request. In other words, the behavior I want here is that adding more tags in the CSV list would include/match more things (e.g. include workflows tagged with "test" OR "production").
Until there is a direct, single call, option to fetch all workflows matching any-of the tags in a CSV list, this is the best workaround I could dream up so far: https://community.n8n.io/t/processing-csv-items-one-by-one/51665
Hey @rthomas67,
It can be made a feature request, We handle those through our support forum and we only use GitHub for bugs. I do agree the documentation could be improved on to make life a lot easier there.
I have created the feature request here: https://community.n8n.io/t/public-api-tags-should-be-or-not-and/51701 feel free to pop a vote on it so we can see what the community think about the idea, Personally I think it makes to have an option to change between or
and and
so you can do either.
For now as there is no bug here I will mark this as solved, Let me know if you have any other questions on this.
Bug Description
Response from /api/v1/workflows only works with a single tag value for the tags query parameter.
Observed
Expectation Based On...
Theory
Maybe typeorm doesn't behave as expected here: https://github.com/n8n-io/n8n/blob/master/packages/cli/src/databases/repositories/tag.repository.ts#L65
To Reproduce
GET http://n8n:5678/api/v1/workflows?tags=test_tag_2 X-N8N-API-KEY: n8n_api_7796d24...replace-me
GET http://n8n:5678/api/v1/workflows?tags=test_tag_1,test_tag_2 X-N8N-API-KEY: n8n_api_7796d24...replace-me