danielgtaylor / danielgtaylor/python-betterproto
Encoding errors while sending aren't thrown because the sending task is started as fire and forget
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 234
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hey there,
I've incorrectly passed a string instead of a message to a grpc field. This will result in an exception which is thrown during encoding in the `__bytes__` method (https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/__init__.py#L634). This method throws an exception that it cannot encode a string as a message.
However the user never sees the exception, because the sending task is started as fire and forget, without handling the exception case. This will result in hidden exceptions. The user only notices that the program doesn't work as expected or it feels like the program has hung up:
```python
sending_task = asyncio.ensure_future(
self._send_messages(stream, request_iterator)
)
```
https://github.com/danielgtaylor/python-betterproto/blob/master/src/betterproto/grpc/grpclib_client.py#L153
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in src/betterproto/grpc/grpclib_client.py, alla chiamata a ensure_future intorno alla riga 153, quindi esamina _send_messages e il metodo __bytes__ in src/betterproto/__init__.py. Riproduci il caso non valido di conversione da stringa a messaggio e traccia il ciclo di vita del task; il lavoro è completato quando l’eccezione di codifica è osservabile dal chiamante invece di rimanere nascosta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- grpc, python
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100