Repository navigation
GH-11635: Keep the data content type in binary mode - #11636
Open
Adrastopoulos wants to merge 3 commits into
Open
Adrastopoulos wants to merge 3 commits into
Adrastopoulos wants to merge 3 commits into
Conversation
Fixes: spring-projects#11635 In binary mode, the `ToCloudEventTransformer` keeps the event data as the payload, but sets the `contentType` header to `application/cloudevents`. The CloudEvents protocol bindings reserve that media type for structured mode and map `datacontenttype` to the content type in binary mode. Consumers such as the `CloudEventMessageConverter` from `cloudevents-spring` reject such a message as an unknown encoding. * Map the `datacontenttype` attribute to `contentType` in the `MessageBuilderMessageWriter`: the input content type, or `application/octet-stream` if absent * Adjust `ToCloudEventTransformerTests` for the new header value Signed-off-by: Gabriel Hall <gabriel.hall@cox.net>
Member
|
Im sorry what is wrong with our docs that you have open PR for just created your own issue: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.md#search-github-issues-first-create-one-if-necessary ? |
Contributor
Author
|
What happened here is that my local clone's CONTRIBUTING.MD predated the change that had that section, and I had made the same oversight in #11636 as well. |
cppwfs
requested changes
Oct 29, 2026
cppwfs
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the contribution!
Contributor
|
@Adrastopoulos Thanks for the feedback. We are in consensus that the PR addresses the issue. Please review my comments on the PR and either address them or reply back. Thank you. |
With the `contentType` header now taken from `datacontenttype`, an input content type such as `application/cloudevents+json` makes a binary mode message look like a structured mode message. Readers then parse the raw payload as a full CloudEvent, so its sender could set the event `id`, `source` and `type`. * Throw an `IllegalStateException` from the `MessageBuilderMessageWriter` for a `datacontenttype` that starts with `application/cloudevents` * Verify the binary mode output with the `CloudEventMessageConverter` from `cloudevents-spring` * Document the binary mode `contentType` and the new failure Signed-off-by: Gabriel Hall <gabriel.hall@cox.net>
…chosen The `MessageBuilderMessageWriter` checked attribute names to map `datacontenttype` to `contentType` and to reject structured mode content types. That rule is about the mode, and `doTransform()` is where the mode is chosen. * Reject `application/cloudevents` content types with `Assert.state()` in `doTransform()` before the binary mode write * Pass the content type to the `MessageBuilderMessageWriter` and set `contentType` in `create()`, where `application/cloudevents` was set before Signed-off-by: Gabriel Hall <gabriel.hall@cox.net>
cppwfs
approved these changes
Nov 3, 2026
cppwfs
left a comment
Contributor
There was a problem hiding this comment.
LGTM
Thank you for your contribution!
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11635
In binary mode,
ToCloudEventTransformernow setscontentTypeto the event'sdatacontenttype: the input content type, orapplication/octet-streamwhen the input has none. That is the value it already writes asce-datacontenttype. Before, it setapplication/cloudevents, which the CloudEvents protocol bindings reserve for structured mode, soCloudEventMessageConverterfromcloudevents-springrejected the message as an unknown encoding.ToCloudEventTransformerTests.convertMessageNoExtensions()now expectstext/plainfrom the input, andnoContentType()expectsapplication/octet-stream.Leaving the input
contentTypeas is would also fix the reported case, but it leaves the header out when the input has none, and the header can hold aMimeTypewhile the attribute is its string form.