question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serverless workflow: actionDataFilter failed to merge nested objects

See original GitHub issue

Describe the bug

Below is my action and the actionDataFilter ${ .collections.test } didn’t work and it only gave me an output like { "test": "sth" }.

{
    "name": "test",
    "type": "operation",
    "actions": [{
            "name": "Collect Inputs",
            "functionRef": {
                "refName": "collect",
                "arguments": {
                    "stepName": "test",
                    "stepVersion": "1.0.0",
                    "subject": "globefish",
                    "bucket": ".destination.bucket",
                    "prefix": ".destination.key",
                    "action": "input"
                }
            },
            "actionDataFilter": {
                "toStateData": "${ .collections.test }"
            }
        }
    ],
    "end": true
}

Expected behavior

The workflow should be { "collections": { "test": "sth" } }.

Actual behavior

{ "test": "sth" }

How to Reproduce?

  1. set actionDataFilter.toStateData with a nested path like a.b
  2. run the workflow
  3. Get the response

Output of uname -a or ver

Linux ubuntu 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version “17.0.5” 2022-10-18 OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8) OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)

Quarkus 2.14.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /home/littlefox/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: /usr/lib/jvm/temurin-17-jdk-amd64 Default locale: en, platform encoding: UTF-8 OS name: “linux”, version: “5.15.79.1-microsoft-standard-wsl2”, arch: “amd64”, family: “unix”

Additional information

No response

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
fjtiradocommented, Dec 14, 2022

It is the “same” issue (different perceiverd result, but same underlying issue) , toStateData is using b to merge and ignoring a (so mergde b object, containing initial m plus function returned greeting is now in two places, under root and under a)
Use results instead of toStateData. So results looks like “${a:{b:{greeting : .greeting}}}” and there is no toStateData. Im going to modify toStateData to behave properly, but till then, use results (which can do esentially the same than toStateData)

1reaction
fjtiradocommented, Dec 13, 2022

Another point that is not clearly set by the spec is what happens is your data is an array and there is already an array in collection.tests, how do you merge them? In Kogito we decided to not merge arrays and replace the value, if existing ( think of merging [1,2,3,4] and [5,4,3,2,1], which will be the expected result?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected behavior merging nested objects · Issue #5089
Array and plain object properties are merged recursively. Other objects and value types are overridden by assignment.
Read more >
How to merge nested objects Javascript? - Stack Overflow
This method is like _. assign except that it recursively merges own and inherited enumerable string keyed properties of source objects into the ......
Read more >
merge-anything - npm
I was looking for: a simple merge function like Object.assign() but deep; supports merging of nested properties; supports TypeScript: the type ...
Read more >
Adding Nested Objects & Lists from Realm (serverless ...
I would like to confirm the process for adding nested Objects & List<>s to an Object from a Realm Function (since there is...
Read more >
How to Merge Deeply Nested Objects in JavaScript
There are many scenarios where we need to merge two objects that may be deeply nested. In this article, we will see how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found