fix: Dapr runtime panic when handle Pub/Sub (dapr#3281) (#967)
* fix: Dapr runtime panic when handle Pub/Sub (dapr#3281) * use uuid to generate Id when Id is missing * skip default value for id and content-type Co-authored-by: Phil Kedy <phil.kedy@gmail.com> Co-authored-by: beiwei.ly <beiwei.ly@alibaba-inc.com> Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
This commit is contained in:
parent
a538b80452
commit
7d2bc9bbdf
|
@ -103,6 +103,19 @@ func FromCloudEvent(cloudEvent []byte, topic, pubsub, traceID string) (map[strin
|
|||
m[TopicField] = topic
|
||||
m[PubsubField] = pubsub
|
||||
|
||||
// specify default value if it's unspecified from the original CloudEvent
|
||||
if m[SourceField] == nil {
|
||||
m[SourceField] = DefaultCloudEventSource
|
||||
}
|
||||
|
||||
if m[TypeField] == nil {
|
||||
m[TypeField] = DefaultCloudEventType
|
||||
}
|
||||
|
||||
if m[SpecVersionField] == nil {
|
||||
m[SpecVersionField] = CloudEventsSpecVersion
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue