Unable to override/set cloudevent properties with metadata during publishing
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 378
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 6
Description
## Expected Behavior
Passing the pre-defined values in metadata should override the values in the cloudevent wrapper when an event is published as described at https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/.
I expected the published event and its wrapper to have the values I provided in the metadata, specifically these two:
cloudevent.id
cloudevent.type
## Actual Behavior
The cloudevent wrapper does not contain an id property, and the type is set to its default value of "com.dapr.event.sent". The publish method seems to ignore the metadata keys to override cloudevent properties. I have observed this no matter which metadata values I pass in.
I have was unable to find a way to view the metadata at any point in the chain to see how dapr is interpreting or even receiving them from the sdk client. Turning dapr logging to debug does not show that an event was published. The only visibility I had was viewing the payload in the pubsub provider (redis stream) and the request body passed to subscribers.
## Steps to Reproduce the Problem
- Create a client instance
- Create a dictionary for the metadata with one or more of the pre-defined cloudevent keys specified
- Publish the event with the PublishEventAsync method
With the following code we created a client and published the event:
```csharp
var client = new DaprClientBuilder()
.UseJsonSerializationOptions(jsonOptions)
UseHttpEndpoint($"http://127.0.0.1:{options.DaprHttpPort}")
.UseGrpcEndpoint($"http://127.0.0.1:{options.DaprGrpcPort}")
.Build();
var createdEvent = new SessionCreated();
metadata = new Dictionary(createdEvent) { Type = "session-created" };
metadata = new Dictionary
Contributor guide
Research direction
Start by reproducing the issue with DaprClientBuilder, PublishEventAsync, the metadata dictionary, and CloudEvent using the example in the report. Trace how cloudevent.id and cloudevent.type are passed through publishing and verify the Redis stream and subscriber request; done means both metadata values appear in the published CloudEvent wrapper.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100