You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The WithCustomAttributes function currently takes a map as input value. Since map is a pointer value, the pointer is passed to msg.Attributes of the pubsub message and then is used throughout the sdk. The map is modified in multiple places. If the pointer to the map is used outside of the event or if the map is reused for multiple events there will be race conditions.
type withCustomAttributes struct{}
func AttributesFrom(ctx context.Context) map[string]string {
return binding.GetOrDefaultFromCtx(ctx, withCustomAttributes{}, make(map[string]string)).(map[string]string)
}
// WithCustomAttributes sets Message Attributes without any CloudEvent logic.
// Note that this function is not intended for CloudEvent Extensions or any `ce-`-prefixed Attributes.
// For these please see `Event` and `Event.SetExtension`.
func WithCustomAttributes(ctx context.Context, attrs map[string]string) context.Context {
return context.WithValue(ctx, withCustomAttributes{}, attrs)
}
The WithCustomAttributes function currently takes a map as input value. Since map is a pointer value, the pointer is passed to msg.Attributes of the pubsub message and then is used throughout the sdk. The map is modified in multiple places. If the pointer to the map is used outside of the event or if the map is reused for multiple events there will be race conditions.
https://github.com/cloudevents/sdk-go/blob/main/protocol/pubsub/v2/attributes.go
https://github.com/cloudevents/sdk-go/blob/main/protocol/pubsub/v2/protocol.go
The text was updated successfully, but these errors were encountered: