cadence
cadence copied to clipboard
Thrift serialization errors for nil/empty map value
Version of Cadence server, and client(which language)
- Server version: tested on 0.21, 0.22 & latest master
- Client version: 0.18.3 (with and without grpc)
- Client langauge: go
- DB: tested on Cassandra and MySQL
Describe the bug Setting a header (via context propagator) or a memo when starting a workflow with a nil (or empty) value in map results in errors similar to this:
"Uncategorized error","service":"cadence-frontend","error":"cadence serialization error: failed to write field 10 (TList): failed to write field 340 (TStruct): failed to write field 140 (TStruct): failed to write field 10 (TMap): invalid [key]: value is nil"
To Reproduce Start a workflow with:
Memo: map[string]interface{}{
"key": []byte(nil),
},
Expected behavior No errors
Additional context This may (or may not) be related to internal type conversions between thrift <-> internal <-> proto. There are already few cases for special nil/empty value handling. It is possible something else is missing.
So there are actually two different issues:
- When setting empty
[]byte
on workflow header via context propagator. The error only happens when using gRPC. And it was already fixed with #4184 and was included in v0.21.3 and later. - Setting empty value
[]byte
on workflow memo. This is not yet fixed and happens on Cassandra only. It is represented asmap<text, blob>
. Bothnil
and empty[]byte
are stored asmemo: {'key': 0x}
which when deserialized becomesnil
. It in turn does not work with Thrift encoder that we still use for sending data to visibility store. It spits out an error to the logs. Also such workflow then has a corrupted visibility record. It is unable to view it via WebUI.