-
Notifications
You must be signed in to change notification settings - Fork 69
Non Uint32Array binary data does not set the CloudEvent's data_base64 value #491
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
Comments
Previously we only considered `Uint32Array` binary data. This was an oversight. This fixes that issue. Fixes: cloudevents#491 Signed-off-by: Lance Ball <lball@redhat.com>
Hi @matthewchngshopback thanks for opening this issue. I have applied a fix in #494 - can you please verify that it addresses your use case? |
* fix: allow `Uint16|8Array` for binary data Previously we only considered `Uint32Array` binary data. This was an oversight. This fixes that issue. Fixes: #491 Signed-off-by: Lance Ball <lball@redhat.com>
@lance Yes, this fix addresses all the issues described. Thanks very much. What do you think the ETA is for 6.0.2? |
@matthewchngshopback We can probably bump a release this week. |
Done |
When binary data, e..
Buffer
orUint8Array
, is not converted toUint32Array
before being set as a CloudEvent's data, thedata_base64
will not be set becauseisBinary()
detection fails. This results in structured mode to go out of spec by not having the expecteddata_base64
attribute but instead include an unexpecteddata
object.If we convert the
Buffer
toUint32Array
and set as CloudEvent's data, then binary mode message body will contain wrong byte sequence as it will be that ofUint32Array
rather than the expectedUint8Array
. This can be overcome by wrapping thebody
fromHTTP.binary()
withBuffer.from(body)
again before feeding itaxios()
. Also,Uint32Array
binary data in binary mode does not work with the providedemitterFor()
as thereq.write()
only allowsBuffer
orUint8Array
.Steps to Reproduce
Expected Behavior
We should be able to pass
TypedArray
directly as data and both the structured and binary modes should create valid bodies that matches the spec.The text was updated successfully, but these errors were encountered: