Skip to content

Commit 47b02d1

Browse files
fix: correct isinstance check to include bytearray in kafka conversion (#267)
The isinstance check in to_structured had a duplicate `bytes` entry instead of `bytearray`, meaning bytearray data would not be correctly base64-encoded in the structured kafka message. Signed-off-by: Artem Muterko <artem@sopho.tech> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 778c2d1 commit 47b02d1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/cloudevents/v1/kafka/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def to_structured(
183183
raise cloud_exceptions.DataMarshallerError(
184184
f"Failed to marshall data with error: {type(e).__name__}('{e}')"
185185
)
186-
if isinstance(data, (bytes, bytes, memoryview)):
186+
if isinstance(data, (bytes, bytearray, memoryview)):
187187
attrs["data_base64"] = base64.b64encode(data).decode("ascii")
188188
else:
189189
attrs["data"] = data

0 commit comments

Comments
 (0)