cloudevents / cloudevents/sdk-csharp

Make datacontenttype value check case-insensitive

Open
#282 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
334
Forks
88
Avg merge
7m
Merged PRs (30d)
2

Description

SDK is using case-sensitive checks when formatting CloudEvents to Json based on "datacontenttype" value. MIME types type and subtype are case insensitive according to the spec.

For example, this code snippet throws exception:
System.ArgumentException: 'JsonEventFormatter cannot serialize data of type System.String with content type 'application/JSON''

CloudEvent cloudEvent = new CloudEvent
{
Id = "event-id",
Type = "event-type",
Source = new Uri("https://cloudevents.io/"),
Time = DateTimeOffset.UtcNow,
DataContentType = "application/JSON",
Data = "text"
};

CloudEventFormatter formatter = new JsonEventFormatter();
var httpContent = cloudEvent.ToHttpContent(ContentMode.Structured, formatter);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JsonEventFormatter and the CloudEvent.DataContentType handling described in the report, then reproduce the application/JSON example. Trace the formatting path and verify that MIME type and subtype comparisons are case-insensitive; done means the example serializes successfully without changing unrelated content types.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.