This changes the deserialization behavior to ignore EOF errors, leaving the undecoded objs Zero-valued
I expect this will better align with user expectations. For example, if you json.Unmarshal a 0-length JSON array into a 1-length slice of struct pointers, the pointer remains zero'ed without err: https://go.dev/play/p/ppz62H1Pqpw
To unmarshal a JSON array into a Go array, Unmarshal decodes JSON array elements into corresponding Go array elements. If the Go array is smaller than the JSON array, the additional JSON array elements are discarded. If the JSON array is smaller than the Go array, the additional Go array elements are set to zero values.
Ie we're getting: unable to decode argument: 0, *interface {}, with json error: EOF in Cadence Replayer where the Workflows happily succeed in our production code. Others have noticed the same: https://github.com/uber-go/cadence-client/issues/1016
This happens when we pass an interface{} to a future.Get(ctx, value) (as a throw away value, we don't actually expect a result):
var result interface{}
future := UpdateActivity.ExecuteRaw(ctx, p)
return future.Get(ctx, &result)
determinism_test.go:174: successfully replayed history
Potential risks
There's an implicit dependency somewhere on the EOF errors from Unmarshal in decoder.defaultDataConverter(data []byte, to ...interface{}). Eg: it's expected that we'll error out on Unmarshal and that all response values will be set to non-Zero values
What changed?
EOF
errors, leaving the undecodedobjs
Zero-valuedI expect this will better align with user expectations. For example, if you
json.Unmarshal
a 0-length JSON array into a 1-length slice of struct pointers, the pointer remains zero'ed without err: https://go.dev/play/p/ppz62H1Pqpwhttps://pkg.go.dev/encoding/json#Unmarshal:~:text=To%20unmarshal%20a%20JSON%20array%20into%20a%20Go%20array
Why?
I've found that the Cadence Replayer fails on many of my team's Workflows:
Ie we're getting:
unable to decode argument: 0, *interface {}, with json error: EOF
in Cadence Replayer where the Workflows happily succeed in our production code. Others have noticed the same: https://github.com/uber-go/cadence-client/issues/1016This happens when we pass an
interface{}
to afuture.Get(ctx, value)
(as a throw away value, we don't actually expect a result):How did you test it?
make test
Potential risks
EOF
errors fromUnmarshal
indecoder.defaultDataConverter(data []byte, to ...interface{})
. Eg: it's expected that we'll error out onUnmarshal
and that all response values will be set to non-Zero values