Open eonpatapon opened 2 years ago
It seems like the problem, or at least part of the problem, looks to me like it could be related to the place in Controller.updateValue
where it's updating the value of c.inst
. The original value of c.inst
had the whole path in; the updated path does not, which means that the Controller.keys
map indexes will change, which is probably why the task is being run twice.
What version of CUE are you using (
cue version
)?0.4.1
Does this issue reproduce with the latest release?
Yes
What did you do?
Using a non root value in flow.Run leads to unexpected task fill results.
To visualize the issue it is handy to print the final value of the flow:
Now using the following cue file:
With the following go code:
Note we are passing
v.LookupPath(cue.ParsePath("a"))
to flow.Run, which is not the root value.Will result in:
Note that the runner is run twice as it reports the full path
a.t1
then the relative patht1
.Therefore flow has updated
a.t1
but has also addeda.a.t1
. (we are in the context ofa
here)Of course, if we close
a
, flow will report an error:The following quick'n dirty patch seems to resolve the issue:
Basically the path of the task should be relative to the flow value because it is used by some
LookupPath
which must be relative to the flow value (https://github.com/cue-lang/cue/blob/master/tools/flow/run.go#L178)Next the labels are used to create the expr that will be unified with the original task value, theses need to be relative as well, it seems.
I have no idea why originally flow was running twice the task though.