-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not alter an event's data attribute #344
fix: do not alter an event's data attribute #344
Conversation
When setting an event's data attribute we were trying to be really clever and this is problematic. Instead, keep the data attribute unchanged. Per the 1.0 specification, the data attribute is still inspected to determine if it is binary, and if so, a data_base64 attribute is added with the contents of the data property encoded as base64. Fixes: cloudevents#343 Signed-off-by: Lance Ball <lball@redhat.com>
Do not merge. I have found a bug in this implementation that I need to fix. Per the spec, this test is incorrect. The spec reads:
// Instead of this
expect(eventDeserialized.data).to.equal({ foo: "bar" });
// It should be
expect(eventDeserialized.data).to.equal(dataBinary); |
@cloudevents/sdk-javascript-maintainers there is an interesting discussion in Slack around this question of binary data: https://cloud-native.slack.com/archives/C9DB5ABAA/p1601416717013400 |
Unless... its datacontenttype is application/json. In that case it should be converted into an object. Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
@cloudevents/sdk-javascript-maintainers PTAL - thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not modifying the data is great.
I think we'll talk about base64 data a bit more in the weekly SDK call too.
Based on the discussion in today's CNCF call, I am going to remove this test and the associated functionality. sdk-javascript/test/integration/message_test.ts Lines 190 to 195 in 5255a19
Edit: I did not remove the test. Instead, I changed it to assert that we do NOT parse binary data even if the |
Signed-off-by: Lance Ball <lball@redhat.com>
Proposed Changes
CloudEvent
so that it never modifies thedata
attributedatacontenttype
property is a content type that we don't support, just set the data attribute - don't throwDescription
When setting an event's data attribute we were trying to be really clever and this is problematic. Instead, keep the data attribute unchanged. Per the 1.0 specification, the data attribute is still inspected to determine if it is binary data, and if so, a data_base64 attribute is added with the contents of the data property encoded as base64.
Fixes: #343
Signed-off-by: Lance Ball lball@redhat.com