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:
Ian Luo 2021-07-09 01:54:36 +08:00 committed by GitHub
parent a538b80452
commit 7d2bc9bbdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -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
}