apache / apache/pulsar-client-python
[python client] message properties are not round-trippable
- Langage dominant
- Python
- Étoiles
- 75
- Forks
- 53
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
**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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par retracer les chemins de sérialisation et de désérialisation de la message property du client Python, en utilisant les clés et les valeurs représentées par des octets dans la reproduction comme premier cas d’échec. Comparez le comportement du producteur et du consommateur et déterminez comment la compatibilité doit être préservée ; le travail est considéré comme terminé lorsque les deux exemples effectuent un aller-retour avec leurs types et valeurs d’origine sans lever UnicodeDecodeError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- distributed-systems
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100