-
Notifications
You must be signed in to change notification settings - Fork 128
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
Error "unable to decode argument" if return nil in local activity #943
Comments
Hi, we just encountered this issue. We use local activities for fetching db objects, and those activities return nil if the object is not found (i.e. we don't consider that to be an error). So as you can imagine, this is a fairly severe issue for our Cadence workflows. Using a custom DataConverter reveals that the ToData() func is never called in this case, only FromData(), which results in FromData() trying to decode zero data. Hence the EOF error. Any timeline on a fix? Currently using Go client 0.12.2 Thank you! |
When local activity returns nil result, it is encoded into nil byte slice ([]byte). Later this is converted into string field ResultJSON within localActivityMarkerData structure. Such casting results in empty string, as this is its zero value in golang. Reverse conversion is not simetrical. Casting empty string back to byte slice results in empty byte slice. This later causes EOF error when trying to decode it back to the original result. The fix is to check whether it is non-empty string and only then assign the result back. This will be simetrical and will not cause decoding error later. This change also adds additional replay tests, that covers this scenario among many other local activity related cases.
When local activity returns nil result, it is encoded into nil byte slice ([]byte). Later this is converted into string field ResultJSON within localActivityMarkerData structure. Such casting results in empty string, as this is its zero value in golang. Reverse conversion is not simetrical. Casting empty string back to byte slice results in empty byte slice. This later causes EOF error when trying to decode it back to the original result. The fix is to check whether it is non-empty string and only then assign the result back. This will be simetrical and will not cause decoding error later. This change also adds additional replay tests, that covers this scenario among many other local activity related cases. Co-authored-by: Bowei Xu <boweixu@uber.com>
Not possible to make LocalActivity that returns nil in result. Workflow fails with
I've made a sample to demonstrate this problem:
https://github.com/olegmedvedev/cadence-local-activity-sample
The text was updated successfully, but these errors were encountered: