dapr / dapr/dotnet-sdk

Custom CloudEvent serialization problem - Data property

Open
#944 1 comment 0 reactions 0 assignees View on GitHub
kind/bug
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
1d 22h
Merged PRs (30d)
5

Description

## Intro
I've stumbled on a problem while publishing events with a custom CloudEvent wrapper.
I'm trying to use custom CloudEvent so that I can specify the type property and use it for routing functionality inside subscribers.

Related to **Allow publishing cloud events directly #868**
The project is using docker-compose to set up the whole infrastructure (pub/sub services, dapr sidecars, Kafka, etc) for testing.
Demo project based on Dapr and Dapr.AspNetCore ver. 1.8, and .Net 5 (Web Api)

## Expected Behavior
Published cloud event JSON schema should look like events published without custom cloud events.

## Actual Behavior

Dapr sidecar log shows the following warning/error:

`level=warning msg="retriable error returned from app while processing pub/sub event , topic: RoutingIntegrationEvent, body: {\"type\":\"https://tools.ietf.org/html/rfc7231#section-6.5.13\",\"title\":\"Unsupported Media Type\",\"status\":415,\"traceId\":\"00-9c97aa770091eb243c1f904fbd88c27f-cfe48e0d27c8fc42-01\"}. status code returned: 415" app_id=subscriber instance=b398cfe88dc9 scope=dapr.runtime type=log ver=1.8.0`

After comparing published events with and without a custom CE wrapper I've noticed that the "data" property is different between those two types of events.
**Specifically, pure event serializes cloud event with "data" property, while custom CE serializes it into uppercase "Data" property.**

## Steps to Reproduce the Problem

1. Clone the repository with the fixed and runnable project (under docker-compose). https://github.com/mzj/PubSubRouting
2. Remove the above-mentioned attribute to reproduce the problem.
3. Run the solution (tested in VS2022)

## Fix
Adding `[JsonPropertyName("data")]` attribute to CloudEvent.Data property, inside Dapr.Client project.

## Release Note
**FIX** Bug in runtime.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.