diff --git a/pkg/pubsub/adapter/converters/pubsub.go b/pkg/pubsub/adapter/converters/pubsub.go index 45d5bc48ce..df0457ae27 100644 --- a/pkg/pubsub/adapter/converters/pubsub.go +++ b/pkg/pubsub/adapter/converters/pubsub.go @@ -18,7 +18,6 @@ package converters import ( "context" - "encoding/json" "time" cloudevents "github.com/cloudevents/sdk-go" @@ -60,16 +59,7 @@ func convertPubSub(ctx context.Context, msg *cepubsub.Message, sendMode ModeType ID: event.ID(), Attributes: msg.Attributes, PublishTime: event.Time(), - } - - var raw json.RawMessage - if err := event.DataAs(&raw); err != nil { - logger.Desugar().Debug("Failed to get data as raw json, using as is.", zap.Error(err)) - // Use data as a byte slice. - msg.Data = event.Data - } else { - // Use data as a raw message. - msg.Data = raw + Data: event.Data, } if err := event.SetData(&PushMessage{ diff --git a/pkg/pubsub/adapter/converters/pubsub_test.go b/pkg/pubsub/adapter/converters/pubsub_test.go index 4d57724c78..d502019256 100644 --- a/pkg/pubsub/adapter/converters/pubsub_test.go +++ b/pkg/pubsub/adapter/converters/pubsub_test.go @@ -116,7 +116,7 @@ func TestConvertCloudPubSub(t *testing.T) { return pubSubPushCloudEvent(map[string]string{ "attribute1": "value1", "Invalid-Attrib#$^": "value2", - }, "\"test data\"") + }, "\"InRlc3QgZGF0YSI=\"") }, }, { name: "Push mode with no attributes", @@ -126,7 +126,7 @@ func TestConvertCloudPubSub(t *testing.T) { }, sendMode: Push, wantEventFn: func() *cloudevents.Event { - return pubSubPushCloudEvent(nil, "\"test data\"") + return pubSubPushCloudEvent(nil, "\"InRlc3QgZGF0YSI=\"") }, }}