Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Collect" Outputs without selector do not merge #320

Open
TheCaffinatedDeveloper opened this issue Mar 3, 2025 · 2 comments
Open

"Collect" Outputs without selector do not merge #320

TheCaffinatedDeveloper opened this issue Mar 3, 2025 · 2 comments

Comments

@TheCaffinatedDeveloper
Copy link

TheCaffinatedDeveloper commented Mar 3, 2025

This could be expected behavior, however, it seems like a bug that when you have multiple "collect" outputs that point to a sink such as Response, that the outputs should merge into a single list by default. Right now, it seems based on evaluation order which one "wins". To overcome this, I need to specify and output selector, then have a function that merges them together which isn't ideal. Example is attached.

Actual Output:

[
  {
    output: 'ABC',
  },
  {
    output: 'DEF',
  },
]

Expected Output:

[
  {
    output: 'ABC',
  },
  {
    output: 'DEF',
  },
  {
    output: 'GHI',
  },
  {
    output: 'JKL',
  },
]

graph (85).json

@ivanmiletic
Copy link
Contributor

Hi @TheCaffinatedDeveloper for now this is by design, reason for this output is that it is not simple to just merge arrays compared to objects. In objects we will do a basic merge but arrays require merge strategy. Adding arrays strategy has caused some issues with passthrough mode of the nodes.

For example merging arrays doesn't mean just adding them, it can also be merging based on prop (property such as "id"). Example if it exists update it if not then add it...

@TheCaffinatedDeveloper
Copy link
Author

TheCaffinatedDeveloper commented Mar 3, 2025

@ivanmiletic Thanks for the quick reply! Makes sense, I can see how a merge strategy could come in handy but also add complexity. I tried to find some documentation related to this behavior which is why I thought it could be a bug.

PS: Zen has continued to shine as a rules engine, keep up the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants