apache / apache/pulsar-client-python

[python client] message properties are not round-trippable

未關閉
#44 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
75
分支
53
PR 合併指標
30 天內沒有已合併 PR

描述

**Describe the bug**
Properties objects on messages can be set to (and published with) values that cannot be deserialized on the far side.

**To Reproduce**
1. Using the Python client, publish a message on any topic with `properties={'foo': b'\x01-\x00\x97'}`
2. Using a Python consumer, consume that message and attempt to access `message.properties()`.
3. Observe that a `UnicodeDecodeError` is raised.
4. Repeat steps 1-3 with `properties={ b'\x01-\x00\x97': 'foo'}`

**Expected behavior**
Properties should be round-trippable: they should be deserialized with the same types and values with which they were set, and should not raise exceptions on deserialization.

There are three possible solutions here:
1. Require that all properties keys and values be `bytes`s in Python. This is easy to implement inside the client, but breaks backwards compatibility.
1. Encode type information along with property keys and values. This is harder to implement inside the client (it doesn't seem like it's using `google.protobuf.Value`s on the wire at the moment, but I may be misreading the code) and deserialize the appropriate types in the consumer.
1. Less preferable: require that all keys and values be `str`s in Python. This is more restrictive than the protocol allows, but is probably simpler to implement.

**Environment:**
MacOS 12 x86, Pulsar standalone 2.10, pulsar client 2.10, Python 3.7.13.

貢獻指南

開啟貢獻指南

研究方向

首先追蹤 Python 用戶端的 message property 序列化與反序列化路徑,將重現中的位元組值鍵和值作為第一個失敗案例。比較 producer 和 consumer 的行為,並確定應如何維持相容性;當兩個範例都能以其原始型別和值完成往返,且不引發 UnicodeDecodeError 時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
distributed-systems
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。