diff --git a/common/persistence/data_blob.go b/common/persistence/data_blob.go index b34694c39ed..bf4204d30e5 100644 --- a/common/persistence/data_blob.go +++ b/common/persistence/data_blob.go @@ -27,20 +27,19 @@ package persistence import ( commonpb "go.temporal.io/api/common/v1" enumspb "go.temporal.io/api/enums/v1" - - "go.temporal.io/server/common/persistence/serialization" ) // NewDataBlob returns a new DataBlob +// TODO: return an UnknowEncodingType error with the actual type string when encodingTypeStr is invalid func NewDataBlob(data []byte, encodingTypeStr string) *commonpb.DataBlob { if len(data) == 0 { return nil } encodingType, ok := enumspb.EncodingType_value[encodingTypeStr] - if !ok || (enumspb.EncodingType(encodingType) != enumspb.ENCODING_TYPE_PROTO3 && - enumspb.EncodingType(encodingType) != enumspb.ENCODING_TYPE_JSON) { - panic(serialization.NewUnknownEncodingTypeError(encodingTypeStr, enumspb.ENCODING_TYPE_JSON, enumspb.ENCODING_TYPE_PROTO3)) + if !ok { + // encodingTypeStr not valid, an error will be returned on deserialization + encodingType = int32(enumspb.ENCODING_TYPE_UNSPECIFIED) } return &commonpb.DataBlob{