cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Thrift serialization errors for nil/empty map value

Open vytautas-karpavicius opened this issue 3 years ago • 1 comments

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.

vytautas-karpavicius avatar Oct 26 '21 18:10 vytautas-karpavicius

So there are actually two different issues:

  1. 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.
  2. Setting empty value []byte on workflow memo. This is not yet fixed and happens on Cassandra only. It is represented as map<text, blob>. Both nil and empty []byte are stored as memo: {'key': 0x} which when deserialized becomes nil. 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.

vytautas-karpavicius avatar Oct 27 '21 11:10 vytautas-karpavicius