Skip to content
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

Closed
meiliang86 opened this issue Feb 28, 2020 · 1 comment
Closed
Assignees

Comments

@meiliang86
Copy link
Contributor

meiliang86 commented Feb 28, 2020

Not possible to make LocalActivity that returns nil in result. Workflow fails with

  "reason": "cadenceInternal:Generic",
  "details": "unable to decode argument: 0, **struct {}, with json error: EOF",

I've made a sample to demonstrate this problem:
https://github.com/olegmedvedev/cadence-local-activity-sample

@zhaytee
Copy link

zhaytee commented Jul 8, 2020

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!

vytautas-karpavicius added a commit to vytautas-karpavicius/cadence-client that referenced this issue Jul 22, 2020
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.
meiliang86 pushed a commit that referenced this issue Jul 22, 2020
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants