Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capitalized (Title case) package name causes invalid gRPC code generation #272

Open
WJCFerguson opened this issue Oct 1, 2021 · 0 comments
Labels
compiler-bug The compiler is broken

Comments

@WJCFerguson
Copy link

WJCFerguson commented Oct 1, 2021

Working with gRPC on v2.0.0b3, if the .proto package name starts with a capital letter, e.g.

package Echo;

Then the generated file becomes significantly different and invalid. Most obviously there is from .. import MessageName as _MessageName__ for the message types and it can't be imported.

For example, take the echo.proto example from the README.md and generate as suggested with python -m grpc_tools.protoc -I . --python_betterproto_out=. echo.proto, it seems fine, but edit it to package Echo; and in Echo/__init__.py you get, among other changes not limited to s/echo/Echo, at the end:

from .. import EchoEchoRequest as _EchoEchoRequest__
from .. import EchoEchoResponse as _EchoEchoResponse__
from .. import EchoEchoStreamResponse as _EchoEchoStreamResponse__

These don't exist, and the package can't be imported.

Found in v2.0.0b3. Thanks!


For completeness, here's the problematic .proto

syntax = "proto3";

package Echo;

message EchoRequest {
  string value = 1;
  // Number of extra times to echo
  uint32 extra_times = 2;
}

message EchoResponse {
  repeated string values = 1;
}

message EchoStreamResponse  {
  string value = 1;
}

service Echo {
  rpc Echo(EchoRequest) returns (EchoResponse);
  rpc EchoStream(EchoRequest) returns (stream EchoStreamResponse);
}
@Gobot1234 Gobot1234 added the bug Something isn't working label Nov 30, 2021
@Gobot1234 Gobot1234 added compiler-bug The compiler is broken and removed bug Something isn't working labels Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-bug The compiler is broken
Projects
None yet
Development

No branches or pull requests

2 participants