danielgtaylor / danielgtaylor/python-betterproto

message names with mutliple constants don't generate correctly when used in grpc

Open
#147 0 comments 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

Given a message such as this:
```proto
message IDMessage {
string id = 1;
}
```

When it is used in an rpc as th einput message, this is generated
```python
async def get_revision(self) -> "Revision":
"""GetRevision returns a revision"""

request = IdMessage()

return await self._unary_unary(
"/somerpc.Name/GetRevision", request, Revision
)
```
if changed to:
```proto
message IdMessage {
string id = 1;
}
```
The generated prototype is then fixed:
```python
async def get_revision(self, *, id: str = "") ->"Revision":
"""GetRevision returns a revision"""

request = IdMessage()
request.id = id

return await self._unary_unary(
"/somerpc.Name/GetRevision", request, Revision
)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the two protobuf message definitions and an RPC using the message as its input. Start by tracing the generated asynchronous gRPC client method and compare the multi-constant and single-constant cases. Done means both cases generate the expected method signature and request-field assignments.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, python
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.