Repository navigation
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 |
grant
left a comment
There was a problem hiding this comment.
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
CloudEventso that it never modifies thedataattributedatacontenttypeproperty 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