Open hossam-nasr opened 1 year ago
FYI @davidmrdavid @ejizba
Thanks @hossam-nasr. I do believe this is probably a breaking change, so I lean towards leaving it as is, and documenting it. I would actually suggest going a step further and adding logic to detect when this edge case is triggered, and warning the user about it.
Discussed offline. Let's not change the current behavior since it's a very narrow edge case (and a breaking change), but let's document it and throw a warning when we detect it
Describe the bug If the return value of an Activity function is an object with at least one key that is the same as the
name
property of an output binding in thefunction.json
file, the orchestration will always receivenull
as the result of the activity.This is due to the way currently the node
@azure/functions
framework allows durable activities to pass results back to the orchestration, in this line here. This line is in place because Activity functions do not set an explicit output binding, but their output should still be set as thereturnValue
of the rpc invocation response.In the check above,
response.outputData.length == 0
will be false if the return value of the activity function is an object with at least one key that has the same name as thename
property of one output binding, owing to this line here. The upshot of it is the framework considers this to be an object of output bindings rather than the output value of the function itself. This is a consequence of the many ways that the current model supports for returning output bindings.Ideally, here's what I would propose:
context.bindings.bindingName = value
should be the only supported way to set output bindings in Durable ActivitiesI understand that this may not be possible to implement because it could be considered a breaking change, or it could also not be worth our time investment to fix. In that case, I would propose that at the very least we should document this limitation somewhere, or log a warning message if we notice a durable activity doing this.
Investigative information
To Reproduce Steps to reproduce the behavior:
DurableFunctionsOrchestratorJS/index.ts
:Hello/index.ts
:Hello/function.json
:Note here that the name property of the blob output binding (
blobOuput
) matches the name of the key in the return value of the activity.Expected behavior
The output of the orchestration should be:
[{ "blobOutput" : "Hello Tokyo!" }, { "blobOutput" : "Hello Seattle!" }, { "blobOutput" : "Hello Cairo!" }]
Actual behavior
The output of the orchestration is instead:
[null, null, null]
Known workarounds
name
property of any output binding.