danielgtaylor / danielgtaylor/python-betterproto

Encoding errors while sending aren't thrown because the sending task is started as fire and forget

Open
#188 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.8k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.